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
189,417
<p>I want to publish a facebook post the moment I publish a new blog on my website.Please help me to get this done.</p>
[ { "answer_id": 189394, "author": "Gixty", "author_id": 14128, "author_profile": "https://wordpress.stackexchange.com/users/14128", "pm_score": 0, "selected": false, "text": "<p>I think I just found it, please corrent me if I am wrong:</p>\n\n<pre><code>$args = array(\n 'status' =&gt; ...
2015/05/26
[ "https://wordpress.stackexchange.com/questions/189417", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60922/" ]
I want to publish a facebook post the moment I publish a new blog on my website.Please help me to get this done.
As `comment_ID` is a unique value, there is no need to include the `post_id` in the arguments. This works fine for me: ``` $args = array( 'status' => 'approve', 'number' => '5', 'parent' => 3194 ); $comments = get_comments($args); ``` This will return 5 approved comments whose parent is the comment wit...
189,426
<p>Is it possible to add a sidebar to navigation menu? </p> <p>I'd like to be able to add sidebars in Appearance > Menus, like I add pages.</p> <p>I have a way of creating extra sidebars, so that's not an issue (I could also just register several dedicated sidebars if need be).</p> <p>Basically I need a way to displ...
[ { "answer_id": 190919, "author": "sohan", "author_id": 69017, "author_profile": "https://wordpress.stackexchange.com/users/69017", "pm_score": 1, "selected": false, "text": "<p>might it can help you for your query :</p>\n\n<blockquote>\n <p>Basically I need a way to display widgets in m...
2015/05/26
[ "https://wordpress.stackexchange.com/questions/189426", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58895/" ]
Is it possible to add a sidebar to navigation menu? I'd like to be able to add sidebars in Appearance > Menus, like I add pages. I have a way of creating extra sidebars, so that's not an issue (I could also just register several dedicated sidebars if need be). Basically I need a way to display widgets in menu, with...
The solution I've wanted looks like this: ``` <?php // Allow HTML descriptions in WordPress Menu remove_filter( 'nav_menu_description', 'strip_tags' ); function my_plugin_wp_setup_nav_menu_item( $menu_item ) { if ( isset( $menu_item->post_type ) && 'nav_menu_item' == $menu_item->post_type) { $menu_item->...
189,437
<p>I have a foreach loop that prints out custom posts which uses a custom taxonomy. The user can then add whatever term/s they like to each post. This then prints out a list of terms on the custom template page; and links them all to a filter. </p> <p>My issue is that when two posts contain the same term; it outputs/...
[ { "answer_id": 189450, "author": "websupporter", "author_id": 48693, "author_profile": "https://wordpress.stackexchange.com/users/48693", "pm_score": 3, "selected": false, "text": "<p>What about this:</p>\n\n<pre><code>&lt;?php \n$already_used = array();\nforeach ( $terms_tags as $term_t...
2015/05/26
[ "https://wordpress.stackexchange.com/questions/189437", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/57571/" ]
I have a foreach loop that prints out custom posts which uses a custom taxonomy. The user can then add whatever term/s they like to each post. This then prints out a list of terms on the custom template page; and links them all to a filter. My issue is that when two posts contain the same term; it outputs/prints the...
I would tend to do this: ``` $terms = array(); $terms_tags = wp_get_post_terms( $query->post->ID, array( 'post_tag' ) ); foreach ( $terms_tags as $term_tag ) { $terms[$term_tag->slug] = '<button class="filter" data-filter=".'.$term_tag->slug.',">'.$term_tag->name.'</button>'; } echo implode($terms,', '); ``` It l...
189,451
<p>I'm using some custom posts types, and, I don't wanna create specific categories for each one.</p> <p>I'd like to use the Post Category in all my Custom Post.</p> <p>Here is a example of my new custom posts type:</p> <p>I know how create new category type for my custom posts, but I don't know how use the regular ...
[ { "answer_id": 189458, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 4, "selected": true, "text": "<p>The documentation for <a href=\"https://codex.wordpress.org/Function_Reference/register_post_type\"><code>reg...
2015/05/26
[ "https://wordpress.stackexchange.com/questions/189451", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73651/" ]
I'm using some custom posts types, and, I don't wanna create specific categories for each one. I'd like to use the Post Category in all my Custom Post. Here is a example of my new custom posts type: I know how create new category type for my custom posts, but I don't know how use the regular categories from posts. ...
The documentation for [`register_post_type`](https://codex.wordpress.org/Function_Reference/register_post_type) mentions a `taxonomies` parameter, giving it a value of `array( 'category' )` will do what you want. There is also the `register_taxonomy_for_object_type` function
189,513
<p>I'm looking to register users without requiring confirmation of their emails (and even better, no password when they register). Basically, I want them to subscribe their mails using wp registration process and then redirect to a page of my choice. </p> <p>I know I can do it with CF7, or a newsletter plugin or whate...
[ { "answer_id": 189458, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 4, "selected": true, "text": "<p>The documentation for <a href=\"https://codex.wordpress.org/Function_Reference/register_post_type\"><code>reg...
2015/05/26
[ "https://wordpress.stackexchange.com/questions/189513", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73678/" ]
I'm looking to register users without requiring confirmation of their emails (and even better, no password when they register). Basically, I want them to subscribe their mails using wp registration process and then redirect to a page of my choice. I know I can do it with CF7, or a newsletter plugin or whatever, but I...
The documentation for [`register_post_type`](https://codex.wordpress.org/Function_Reference/register_post_type) mentions a `taxonomies` parameter, giving it a value of `array( 'category' )` will do what you want. There is also the `register_taxonomy_for_object_type` function
189,543
<p>So, I have following <code>php</code> code:</p> <pre><code>&lt;?php global $my_profile; ?&gt; &lt;?php if (is_user_logged_in()) : ?&gt; &lt;div class="img" data-key="profile"&gt;&lt;?php echo get_avatar( get_current_user_id(), 64 ); ?&gt;&lt;/div&gt; &lt;?php endif; ?&gt; </code></pre> <p>It pulls the profile ...
[ { "answer_id": 189562, "author": "mishu", "author_id": 64607, "author_profile": "https://wordpress.stackexchange.com/users/64607", "pm_score": 1, "selected": false, "text": "<p>You can try this out :</p>\n\n<blockquote>\n<pre><code>&lt;?php global $my_profile; ?&gt;\n&lt;?php if (is_user...
2015/05/27
[ "https://wordpress.stackexchange.com/questions/189543", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/67604/" ]
So, I have following `php` code: ``` <?php global $my_profile; ?> <?php if (is_user_logged_in()) : ?> <div class="img" data-key="profile"><?php echo get_avatar( get_current_user_id(), 64 ); ?></div> <?php endif; ?> ``` It pulls the profile picture of currently logged in user. I am trying to add this to one of th...
Add to your functions file and use [wp\_nav\_menu\_items](https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-includes/nav-menu-template.php#L386) ``` add_filter('wp_nav_menu_items','wpsites_add_avatar_to_nav', 10, 2); function wpsites_add_avatar_to_nav( $items, $args ) { if( $args->theme_location == 'primar...
189,554
<p>I have recently had an issue where I have been unable to install the WP Smush Pro plugin because I don't have the Manual Install or One-Click Installation options available.</p> <p>I came across <a href="http://www.narga.net/stop-fix-wordpress-ask-for-ftp-credentials-upgrade-install-delete-themes-plugins/">this pos...
[ { "answer_id": 189570, "author": "websupporter", "author_id": 48693, "author_profile": "https://wordpress.stackexchange.com/users/48693", "pm_score": 6, "selected": true, "text": "<p>This is just, how I understood the idea of the <a href=\"https://codex.wordpress.org/Filesystem_API\">Wor...
2015/05/27
[ "https://wordpress.stackexchange.com/questions/189554", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38865/" ]
I have recently had an issue where I have been unable to install the WP Smush Pro plugin because I don't have the Manual Install or One-Click Installation options available. I came across [this post](http://www.narga.net/stop-fix-wordpress-ask-for-ftp-credentials-upgrade-install-delete-themes-plugins/) which suggested...
This is just, how I understood the idea of the [WordPress File API](https://codex.wordpress.org/Filesystem_API). If it is wrong, please downvote :) Okay. If you upload a file, this file has an owner. If you upload your file with FTP, you login and the file will be owned by the FTP user. Since you have the credentials,...
189,584
<p>I am trying to output all the tags (custom taxonomy) without link, and add special class to current post tags. For example: if there are 10 tags but current post has 3 of them applied, then it should display all the 10 tags without link but only 3 tags should have special class.</p> <p>I am currently using:</p> <p...
[ { "answer_id": 189570, "author": "websupporter", "author_id": 48693, "author_profile": "https://wordpress.stackexchange.com/users/48693", "pm_score": 6, "selected": true, "text": "<p>This is just, how I understood the idea of the <a href=\"https://codex.wordpress.org/Filesystem_API\">Wor...
2015/05/27
[ "https://wordpress.stackexchange.com/questions/189584", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/69363/" ]
I am trying to output all the tags (custom taxonomy) without link, and add special class to current post tags. For example: if there are 10 tags but current post has 3 of them applied, then it should display all the 10 tags without link but only 3 tags should have special class. I am currently using: ``` $ter...
This is just, how I understood the idea of the [WordPress File API](https://codex.wordpress.org/Filesystem_API). If it is wrong, please downvote :) Okay. If you upload a file, this file has an owner. If you upload your file with FTP, you login and the file will be owned by the FTP user. Since you have the credentials,...
189,627
<p>how do you make the user role "contributor" to be same as the user role "seller" by using functions.php</p> <p>I've tried user role editor, but it seems to be the dokan multivendor plugin has set only into user role "seller" but I wanted to make the "contributor" to be same as the seller role</p>
[ { "answer_id": 189629, "author": "sakibmoon", "author_id": 23214, "author_profile": "https://wordpress.stackexchange.com/users/23214", "pm_score": 1, "selected": false, "text": "<p>Contributor has the following capabilities</p>\n\n<ul>\n<li>delete_posts</li>\n<li>edit_posts</li>\n<li>rea...
2015/05/27
[ "https://wordpress.stackexchange.com/questions/189627", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73729/" ]
how do you make the user role "contributor" to be same as the user role "seller" by using functions.php I've tried user role editor, but it seems to be the dokan multivendor plugin has set only into user role "seller" but I wanted to make the "contributor" to be same as the seller role
Contributor has the following capabilities * delete\_posts * edit\_posts * read You can create the "Seller" role to have same capabilities as Contributor ``` add_role( 'seller', __( 'Seller' ), array( 'read' => true, 'edit_posts' => true, 'delete_posts' => true, ) );...
189,668
<p>I've been searching for a couple hours and consulted multiple posts, but I seem to get this to work.</p> <p>I have this weird bug where users cannot see their drafts of a custom post type if they don't assign a category to them. So if they just click 'save as draft' and want to go back to it later, it won't be visi...
[ { "answer_id": 189672, "author": "mishu", "author_id": 64607, "author_profile": "https://wordpress.stackexchange.com/users/64607", "pm_score": 4, "selected": true, "text": "<p>Use the save_post action hook and in the call back function use wp_set_object_terms( $object_id, $terms, $taxono...
2015/05/28
[ "https://wordpress.stackexchange.com/questions/189668", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70893/" ]
I've been searching for a couple hours and consulted multiple posts, but I seem to get this to work. I have this weird bug where users cannot see their drafts of a custom post type if they don't assign a category to them. So if they just click 'save as draft' and want to go back to it later, it won't be visible to the...
Use the save\_post action hook and in the call back function use wp\_set\_object\_terms( $object\_id, $terms, $taxonomy, $append ) function. For your custom post type the code can be like this ``` function save_book_meta( $post_id, $post, $update ) { $slug = 'book'; //Slug of CPT // If this isn't a 'book' ...
189,692
<p>I'm raising this problem because I don't find a latest answer and the problem still exist to me.</p> <p>I'm running wordpress 4.2.2 with <a href="http://theme.co/x/" rel="nofollow">x theme</a> when I'm editing the content via WP default editor (tinymce). I'm having lot of problem with HTML format. For example if I ...
[ { "answer_id": 190036, "author": "Mathew Tinsley", "author_id": 69793, "author_profile": "https://wordpress.stackexchange.com/users/69793", "pm_score": 4, "selected": true, "text": "<p>You can disable the visual editor entirely in your <a href=\"https://codex.wordpress.org/Users_Your_Pro...
2015/05/28
[ "https://wordpress.stackexchange.com/questions/189692", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/69455/" ]
I'm raising this problem because I don't find a latest answer and the problem still exist to me. I'm running wordpress 4.2.2 with [x theme](http://theme.co/x/) when I'm editing the content via WP default editor (tinymce). I'm having lot of problem with HTML format. For example if I edit the content in VISUAL/TEXT mode...
You can disable the visual editor entirely in your [profile settings](https://codex.wordpress.org/Users_Your_Profile_Screen). If you need to disable it on a per page basis, take a look at [this answer](https://wordpress.stackexchange.com/questions/12370/disable-wysiwyg-editor-only-when-creating-a-page/18149#18149). Us...
189,693
<p>I know that you can remove the editor section of the page editor page ( :/) depending on the template chosen using <code>add_action( 'load-page.php', 'hide_editor_function' );</code> (with proper functionality of course). The problem with this though, as you should be able to tell, is that this will only work on a p...
[ { "answer_id": 189716, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 2, "selected": true, "text": "<p>If you want to toggle the editor \"on the fly\", you'll need to revert to a pure JavaScript solution, and o...
2015/05/28
[ "https://wordpress.stackexchange.com/questions/189693", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73761/" ]
I know that you can remove the editor section of the page editor page ( :/) depending on the template chosen using `add_action( 'load-page.php', 'hide_editor_function' );` (with proper functionality of course). The problem with this though, as you should be able to tell, is that this will only work on a page load/reloa...
If you want to toggle the editor "on the fly", you'll need to revert to a pure JavaScript solution, and only ever "visually" hide it (as opposed to removing it server-side): ``` function wpse_189693_hide_on_template_toggle() { $screen = get_current_screen(); if ( $screen && $screen->id === 'page' ) : ?...
189,714
<p>Hoping for some help here as I'm scratching my head. I'm trying to create a custom login page for my site which has gone rather well until I try to add in a custom CSS to make it look pretty. I'm trying to add in the style-login.css file using the following:</p> <pre><code>// add a custom css file for login page ...
[ { "answer_id": 189715, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": true, "text": "<p>Your code works just fine for me, other than small kink that <code>all</code> should be quoted string <code>'all'</c...
2015/05/28
[ "https://wordpress.stackexchange.com/questions/189714", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73777/" ]
Hoping for some help here as I'm scratching my head. I'm trying to create a custom login page for my site which has gone rather well until I try to add in a custom CSS to make it look pretty. I'm trying to add in the style-login.css file using the following: ``` // add a custom css file for login page function nb_logi...
Your code works just fine for me, other than small kink that `all` should be quoted string `'all'`. But as far as WP queue is concerned it's valid.
189,725
<p>I'm using <code>FontAwesome</code> and hence I need to include some extra code next to <code>parent menu</code> options that have a <code>sub-menu</code>, such as:</p> <pre><code>&lt;li&gt; &lt;a href=""&gt;About &lt;span class="fa fa-angle-down"&gt;&lt;/span&gt;&lt;/a&gt; &lt;ul class="sub-menu"&gt; ...
[ { "answer_id": 189837, "author": "Flamenco", "author_id": 72914, "author_profile": "https://wordpress.stackexchange.com/users/72914", "pm_score": 1, "selected": false, "text": "<p>Filtering menu items is something that I don't enjoy much. :-) So I'm going to give you another idea. Inste...
2015/05/28
[ "https://wordpress.stackexchange.com/questions/189725", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1839/" ]
I'm using `FontAwesome` and hence I need to include some extra code next to `parent menu` options that have a `sub-menu`, such as: ``` <li> <a href="">About <span class="fa fa-angle-down"></span></a> <ul class="sub-menu"> <li><a href="">About Us</a></li> <li><a href="">Why Choose Us?</a></li> ...
Ok, figured it out. You need to use a `walker` instance which is passed in as an instance via the `wp_nav_menu` function, like so: ``` wp_nav_menu( array( 'menu' => 'main', 'container' => 'div', 'container_id' => 'mr_nav', 'container_class...
189,728
<p>I have a site where YouTube video IDs are used as a post's title. This mostly works fine, except some valid YouTube video IDs have two consecutive dashes. For example, "j--c0wP54JU" is getting automatically modified by wordpress to be "j-c0wP54JU" (Note the single dash).</p> <p>When I try to manually edit the perma...
[ { "answer_id": 189729, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 4, "selected": true, "text": "<p>Regarding the <strong>why</strong> part, I think I've traced this to the following <a href=\"https://github.co...
2015/05/28
[ "https://wordpress.stackexchange.com/questions/189728", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49254/" ]
I have a site where YouTube video IDs are used as a post's title. This mostly works fine, except some valid YouTube video IDs have two consecutive dashes. For example, "j--c0wP54JU" is getting automatically modified by wordpress to be "j-c0wP54JU" (Note the single dash). When I try to manually edit the permalink from ...
Regarding the **why** part, I think I've traced this to the following [line](https://github.com/WordPress/WordPress/blob/master/wp-includes/formatting.php#L1378): ``` $title = preg_replace('|-+|', '-', $title); ``` within the [`sanitize_title_with_dashes()`](https://github.com/WordPress/WordPress/blob/master/wp-incl...
189,733
<p>I have been running a network of WordPress sites (Multisite) since version 3.8.1. I've been constantly updating plugins and core. At some point, I discovered that uploading new images yields broken results. </p> <p>When I upload a file it goes to <code>wp-content/blogs.dir/7/files</code>, 7 being the blog id. WordP...
[ { "answer_id": 189729, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 4, "selected": true, "text": "<p>Regarding the <strong>why</strong> part, I think I've traced this to the following <a href=\"https://github.co...
2015/05/28
[ "https://wordpress.stackexchange.com/questions/189733", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48751/" ]
I have been running a network of WordPress sites (Multisite) since version 3.8.1. I've been constantly updating plugins and core. At some point, I discovered that uploading new images yields broken results. When I upload a file it goes to `wp-content/blogs.dir/7/files`, 7 being the blog id. WordPress, for some reason...
Regarding the **why** part, I think I've traced this to the following [line](https://github.com/WordPress/WordPress/blob/master/wp-includes/formatting.php#L1378): ``` $title = preg_replace('|-+|', '-', $title); ``` within the [`sanitize_title_with_dashes()`](https://github.com/WordPress/WordPress/blob/master/wp-incl...
189,736
<p>I have a large wordpress database:</p> <p>rows in key tables:</p> <blockquote> <p>730K wp_posts<br> 404K wp_terms<br> 752K wp_term_relationships<br> 27K wp_term_taxonomy<br> 1.8 Million wp_postmeta<br></p> </blockquote> <p>The issue is that I have a query <strong>that takes 5 seconds to complete</strong> an...
[ { "answer_id": 189781, "author": "Kladskull", "author_id": 63596, "author_profile": "https://wordpress.stackexchange.com/users/63596", "pm_score": 3, "selected": false, "text": "<p>I had the exact same issue. The problem is not one that can be fixed without modifying some code that you p...
2015/05/28
[ "https://wordpress.stackexchange.com/questions/189736", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51263/" ]
I have a large wordpress database: rows in key tables: > > 730K wp\_posts > 404K wp\_terms > 752K wp\_term\_relationships > 27K > wp\_term\_taxonomy > > 1.8 Million wp\_postmeta > > > > The issue is that I have a query **that takes 5 seconds to complete** and I want to optimize the query before ...
So what I'm going to do going forward if I use wordpress for this project is to create a reverse post id index. I don't think this is the "correct" answer and some people will definitely outright disagree with this approach but this is working for me in production. I got the idea from reading this blog post here: <ht...
189,739
<p>I've made a custom post type "brands". I have a custom template that display's these brands on this page: <a href="http://www.southernms.com/new/brands/" rel="nofollow">http://www.southernms.com/new/brands/</a></p> <p>I also want these brands added to the homepage. So I am using a widget to show them on the homepag...
[ { "answer_id": 189743, "author": "KVDD", "author_id": 54304, "author_profile": "https://wordpress.stackexchange.com/users/54304", "pm_score": 1, "selected": false, "text": "<p>This is what I changed it to, and it seems to be working on the Homepage without extra added code.</p>\n\n<pre><...
2015/05/28
[ "https://wordpress.stackexchange.com/questions/189739", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54304/" ]
I've made a custom post type "brands". I have a custom template that display's these brands on this page: <http://www.southernms.com/new/brands/> I also want these brands added to the homepage. So I am using a widget to show them on the homepage: <http://www.southernms.com/new/> My problem is. On the brands page, you...
As already mentioned, don't use `query_posts()`. Even the WordPress docs state this: > > Note: ***This function isn't meant to be used by plugins or themes***. As > explained later, there are better, more performant options to alter > the main query. query\_posts() is overly simplistic and problematic way > to mo...
189,746
<p>I have been looking around for the past few hours and I am starting to be kind of desperate...</p> <p>I have created a plugin to add my custom post type "project" (making a new portfolio)...</p> <p>In this plugin, I have the function file, and a template file single-project.php and also a template part folder with...
[ { "answer_id": 189743, "author": "KVDD", "author_id": 54304, "author_profile": "https://wordpress.stackexchange.com/users/54304", "pm_score": 1, "selected": false, "text": "<p>This is what I changed it to, and it seems to be working on the Homepage without extra added code.</p>\n\n<pre><...
2015/05/28
[ "https://wordpress.stackexchange.com/questions/189746", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73792/" ]
I have been looking around for the past few hours and I am starting to be kind of desperate... I have created a plugin to add my custom post type "project" (making a new portfolio)... In this plugin, I have the function file, and a template file single-project.php and also a template part folder with content-single-p...
As already mentioned, don't use `query_posts()`. Even the WordPress docs state this: > > Note: ***This function isn't meant to be used by plugins or themes***. As > explained later, there are better, more performant options to alter > the main query. query\_posts() is overly simplistic and problematic way > to mo...
189,758
<p>I would like to know How can i redirect users to their profile after they log in to my website.</p> <p>Right now, when users log in, they get riderected to the home page but i would like for them to get redirected to their respective profile.</p> <p>thanks in advance </p>
[ { "answer_id": 189771, "author": "flomei", "author_id": 65455, "author_profile": "https://wordpress.stackexchange.com/users/65455", "pm_score": 0, "selected": false, "text": "<p>You can use the <code>wp_authenticate</code>-hook (see <a href=\"https://codex.wordpress.org/Plugin_API/Action...
2015/05/28
[ "https://wordpress.stackexchange.com/questions/189758", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73798/" ]
I would like to know How can i redirect users to their profile after they log in to my website. Right now, when users log in, they get riderected to the home page but i would like for them to get redirected to their respective profile. thanks in advance
Try: ``` function custom_user_login_redirect( redirect_to, $redirect_to_raw, $user ) { $redirect_to = bp_loggedin_user_domain(); return $redirect_to; } add_filter('bp_login_redirect','custom_user_login_redirect',10,3); ```
189,760
<p>How do I find out which taxonomy triggered the save?</p> <pre><code>add_action ( 'edited_' . $taxonomy-&gt;name, 'save_taxonomy' ); function save_taxonomy( $term_id ) { $term = get_term( $term_id, $taxonomy ); // Where can I get the taxonomy? } </code></pre>
[ { "answer_id": 189762, "author": "Mark", "author_id": 8757, "author_profile": "https://wordpress.stackexchange.com/users/8757", "pm_score": 1, "selected": false, "text": "<p>This seems to work, don't know if it's the correct approach. </p>\n\n<pre><code>add_action ( 'edited_' . $taxon...
2015/05/28
[ "https://wordpress.stackexchange.com/questions/189760", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8757/" ]
How do I find out which taxonomy triggered the save? ``` add_action ( 'edited_' . $taxonomy->name, 'save_taxonomy' ); function save_taxonomy( $term_id ) { $term = get_term( $term_id, $taxonomy ); // Where can I get the taxonomy? } ```
This seems to work, don't know if it's the correct approach. ``` add_action ( 'edited_' . $taxonomy->name, function( $term_id ) use ( $taxonomy ) { $term = get_term( $term_id, $taxonomy->name ); }); ```
189,767
<p>I am looking for a simple clean solution when someone visits my <strong>homepage</strong> with a mobile device. Should I use something like Mobile Detect? I've seen many plugins with lots of downvotes or crashing.</p> <p>Is it otherwise possible to only add a javascript thingie on the homepage only?</p> <pre><code...
[ { "answer_id": 189803, "author": "tushonline", "author_id": 15946, "author_profile": "https://wordpress.stackexchange.com/users/15946", "pm_score": -1, "selected": false, "text": "<p>Javascript Thingie!! \nYou should have tried Mobile Detect first. That should suffice your requirement. I...
2015/05/28
[ "https://wordpress.stackexchange.com/questions/189767", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73800/" ]
I am looking for a simple clean solution when someone visits my **homepage** with a mobile device. Should I use something like Mobile Detect? I've seen many plugins with lots of downvotes or crashing. Is it otherwise possible to only add a javascript thingie on the homepage only? ``` if ('ontouchstart' in window) wi...
You could use [`wp_is_mobile`](https://codex.wordpress.org/Function_Reference/wp_is_mobile) with [`wp_redirect`](https://codex.wordpress.org/Function_Reference/wp_redirect) ``` if ( wp_is_mobile() AND is_front_page() ) { wp_redirect( $location, $status ); exit; } ``` You can add the js directly to a front-page.p...
189,774
<p>Why $has_children doesn't work here?</p> <pre><code>class walker_name extends Walker_Nav_Menu{ function start_el(&amp;$output, $item, $depth, $args) { $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; $class_names = $value = ''; $classes = empty( $item-&gt;classes ) ? a...
[ { "answer_id": 189778, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 1, "selected": false, "text": "<p>I am not sure why you think that <code>$args-&gt;has_children</code> (or <code>$args['has_children']</code>)...
2015/05/28
[ "https://wordpress.stackexchange.com/questions/189774", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37529/" ]
Why $has\_children doesn't work here? ``` class walker_name extends Walker_Nav_Menu{ function start_el(&$output, $item, $depth, $args) { $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; $class_names = $value = ''; $classes = empty( $item->classes ) ? array() : (array) $it...
I just resolved this issue! Woo hoo! The thing is that using `var_dump($args)` shows a lot stuff like so: ``` object(stdClass)#152 (16) { ["menu"]=> object(WP_Term)#145 (10) { ["term_id"]=> int(2) ["name"]=> string(9) "Main menu" ["slug"]=> string(9) "main-menu" ["term_group"]=> int(0) ["term_taxonomy_id"]=> int(2) ["...
189,788
<p>So, I understand how to target a specific menu using the following to add a custom code.</p> <pre><code>&lt;?php wp_nav_menu( array( 'menu' =&gt; 'Project Nav', // do not fall back to first non-empty menu 'theme_location' =&gt; '__no_such_location', // do not fall back to wp_page_menu() 'fallback_cb' =&...
[ { "answer_id": 189789, "author": "Marek", "author_id": 54031, "author_profile": "https://wordpress.stackexchange.com/users/54031", "pm_score": 1, "selected": false, "text": "<p>Presonally, I would use some CSS workaround. In menu administration you can add CSS class to menu item (if the ...
2015/05/29
[ "https://wordpress.stackexchange.com/questions/189788", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/67604/" ]
So, I understand how to target a specific menu using the following to add a custom code. ``` <?php wp_nav_menu( array( 'menu' => 'Project Nav', // do not fall back to first non-empty menu 'theme_location' => '__no_such_location', // do not fall back to wp_page_menu() 'fallback_cb' => false ) ); ?> ``` ...
This is relatively easily done using the `walker_nav_menu_start_el` filter (without all that PHP tag spam): ``` function nav_replace_wpse_189788($item_output, $item) { // var_dump($item_output, $item); if ('Profile' == $item->title) { global $my_profile; // no idea what this does? if (is_user_logged_in()...
189,816
<p>I have created a custom post type named 14kgold. Under this I defined two categories: Symphony and Noir. Now I added items/ products to each category. When I open a product under one category i.e. symphony for example, It takes me to single.php. Till now everything is working fine. But when I do next, It shows me th...
[ { "answer_id": 189789, "author": "Marek", "author_id": 54031, "author_profile": "https://wordpress.stackexchange.com/users/54031", "pm_score": 1, "selected": false, "text": "<p>Presonally, I would use some CSS workaround. In menu administration you can add CSS class to menu item (if the ...
2015/05/29
[ "https://wordpress.stackexchange.com/questions/189816", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/36324/" ]
I have created a custom post type named 14kgold. Under this I defined two categories: Symphony and Noir. Now I added items/ products to each category. When I open a product under one category i.e. symphony for example, It takes me to single.php. Till now everything is working fine. But when I do next, It shows me the n...
This is relatively easily done using the `walker_nav_menu_start_el` filter (without all that PHP tag spam): ``` function nav_replace_wpse_189788($item_output, $item) { // var_dump($item_output, $item); if ('Profile' == $item->title) { global $my_profile; // no idea what this does? if (is_user_logged_in()...
189,820
<p>I have created A custom post type as mentioned in <a href="https://wordpress.stackexchange.com/questions/189816/show-posts-of-one-category-only-with-custom-taxonomy-on-single-php">my older question</a></p> <p>When I try to use get_the_category() function to retrieve the category of the post(if it is symphony or no...
[ { "answer_id": 189900, "author": "Brad Dalton", "author_id": 9884, "author_profile": "https://wordpress.stackexchange.com/users/9884", "pm_score": 1, "selected": false, "text": "<p>Check the 3rd and 4th parameters for previous and <a href=\"https://codex.wordpress.org/Function_Reference/...
2015/05/29
[ "https://wordpress.stackexchange.com/questions/189820", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/36324/" ]
I have created A custom post type as mentioned in [my older question](https://wordpress.stackexchange.com/questions/189816/show-posts-of-one-category-only-with-custom-taxonomy-on-single-php) When I try to use get\_the\_category() function to retrieve the category of the post(if it is symphony or noir). It returns "Arr...
Check the 3rd and 4th parameters for previous and [`next_post_link`](https://codex.wordpress.org/Function_Reference/next_post_link): **in\_same\_term** (boolean) (optional) Indicates whether next post must be within the same taxonomy term as the current post. If set to 'true', only posts from the current taxonomy term...
189,827
<p>When changing the slug for a page (clicking OK) an ajax call is made to check if the slug is available and to generate a different one if not. Does anyone know if there is any logging for this, or any way to investigate what's happening? Even knowing where the source is for this process would be helpful.</p> <p>I'm...
[ { "answer_id": 189832, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": false, "text": "<p>Firebug's \"Network\" tab should tell you, or something more aggressive like Wireshark. </p>\n\n<p>The <code...
2015/05/29
[ "https://wordpress.stackexchange.com/questions/189827", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/57301/" ]
When changing the slug for a page (clicking OK) an ajax call is made to check if the slug is available and to generate a different one if not. Does anyone know if there is any logging for this, or any way to investigate what's happening? Even knowing where the source is for this process would be helpful. I'm experienc...
If we trace the Ajax process after you click `OK`, we would walk the following path from the core and into the database: ``` Press OK on Edit slug: \ \-> AJAX POST request with action=sample-permalink Action: wp_ajax_sample-permalink \ \-> function: wp_ajax_sample_permalink() \ \-> f...
189,855
<p>Is there a built-in workflow or process for running one-time wordpress database updates relating to things like taxonomy, new categories, filters, hooks, plugin setup, etc? </p> <p>Right now I'm putting all of these programmatic database updates into my custom functions.php file. This feels wrong since the code wil...
[ { "answer_id": 189832, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": false, "text": "<p>Firebug's \"Network\" tab should tell you, or something more aggressive like Wireshark. </p>\n\n<p>The <code...
2015/05/29
[ "https://wordpress.stackexchange.com/questions/189855", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73514/" ]
Is there a built-in workflow or process for running one-time wordpress database updates relating to things like taxonomy, new categories, filters, hooks, plugin setup, etc? Right now I'm putting all of these programmatic database updates into my custom functions.php file. This feels wrong since the code will run repe...
If we trace the Ajax process after you click `OK`, we would walk the following path from the core and into the database: ``` Press OK on Edit slug: \ \-> AJAX POST request with action=sample-permalink Action: wp_ajax_sample-permalink \ \-> function: wp_ajax_sample_permalink() \ \-> f...
189,891
<p>this is the header section for enqueueing my scripts</p> <pre><code>&lt;?php wp_enqueue_script( 'menu' ); wp_enqueue_script('thumbnail'); ?&gt; &lt;?php wp_head(); ?&gt; &lt;link rel="stylesheet" href="&lt;?php bloginfo('stylesheet_url'); ?&gt;" type="text/css" /&gt; &lt;script type="text/javascript" src="&lt;?p...
[ { "answer_id": 189892, "author": "Robert hue", "author_id": 22461, "author_profile": "https://wordpress.stackexchange.com/users/22461", "pm_score": 2, "selected": true, "text": "<p>You should enqueue scripts in <code>functions.php</code> itself with <code>wp_enqueue_scripts</code> hook. ...
2015/05/30
[ "https://wordpress.stackexchange.com/questions/189891", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73600/" ]
this is the header section for enqueueing my scripts ``` <?php wp_enqueue_script( 'menu' ); wp_enqueue_script('thumbnail'); ?> <?php wp_head(); ?> <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" /> <script type="text/javascript" src="<?php get_template_directory_uri();?>/js/menu-e...
You should enqueue scripts in `functions.php` itself with `wp_enqueue_scripts` hook. Like this. ``` function my_jsfile() { wp_register_script( 'menu', get_template_directory_uri() . '/js/menu-effect.js', array() ); wp_register_script( 'thumbnail', get_template_directory_uri() . '/js/thumbnail-effect.js', array() ...
189,901
<p>I am trying to choose different databases for admin and user to decrease the load on database. in wp-config.php when i am trying to use the code</p> <pre><code>if(is_admin()) { define('DB_NAME', 'wp_db'); } else { define('DB_NAME', 'other_wp_db'); } </code></pre> <p>both databases uses same user name and password....
[ { "answer_id": 189903, "author": "Marek", "author_id": 54031, "author_profile": "https://wordpress.stackexchange.com/users/54031", "pm_score": 2, "selected": false, "text": "<p>It's too early to use this WP built-in function. You can use it in some plugin or theme files, but not when WP ...
2015/05/30
[ "https://wordpress.stackexchange.com/questions/189901", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73859/" ]
I am trying to choose different databases for admin and user to decrease the load on database. in wp-config.php when i am trying to use the code ``` if(is_admin()) { define('DB_NAME', 'wp_db'); } else { define('DB_NAME', 'other_wp_db'); } ``` both databases uses same user name and password. I am getting an error o...
It's too early to use this WP built-in function. You can use it in some plugin or theme files, but not when WP enviroment is still loading. As I am not really sure if your intention is really correct, you have to use some other way (with PHP native functions) to distinct between front-end and administration. For examp...
189,911
<p>i tried many conditions to my footer.php section to include this function in my front page only and not on blog page...but it just pops up on both pages or none of them...can anyone explain the fault ?</p> <pre><code> &lt;?php if( is_home() &amp;&amp; is_front_page() ) : ?&gt; &lt;div id="blurbs"&gt; &lt;ul...
[ { "answer_id": 189915, "author": "Prasad Nevase", "author_id": 62283, "author_profile": "https://wordpress.stackexchange.com/users/62283", "pm_score": 0, "selected": false, "text": "<ul>\n<li>On the site front page, is_front_page() will always return TRUE,\nregardless of whether the site...
2015/05/30
[ "https://wordpress.stackexchange.com/questions/189911", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73600/" ]
i tried many conditions to my footer.php section to include this function in my front page only and not on blog page...but it just pops up on both pages or none of them...can anyone explain the fault ? ``` <?php if( is_home() && is_front_page() ) : ?> <div id="blurbs"> <ul> <?php $the_query = new WP_Query( ...
``` <?php if( is_front_page() ) : ?> ``` is\_home relates to the posts page according to your reading settings. is\_front\_page always returns true on the front page.
189,965
<p>This is what I want: I have made a Custom Post Type in my theme and it shows in my home too, but the problem is that tha CPT takes the same elements and style of a default post in Wordpress, how I can assign a template for how my CPT is displayed at my home? When I say home I mean www.mysite.com (The content of inde...
[ { "answer_id": 189974, "author": "Krzysiek Dróżdż", "author_id": 34172, "author_profile": "https://wordpress.stackexchange.com/users/34172", "pm_score": 1, "selected": false, "text": "<p>There is only one home/frontpage, so I'm not sure, what are you trying to achieve...</p>\n\n<p>Let's ...
2015/05/30
[ "https://wordpress.stackexchange.com/questions/189965", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73891/" ]
This is what I want: I have made a Custom Post Type in my theme and it shows in my home too, but the problem is that tha CPT takes the same elements and style of a default post in Wordpress, how I can assign a template for how my CPT is displayed at my home? When I say home I mean www.mysite.com (The content of index.p...
I am thinking you probably want [`get_template_part()`](https://codex.wordpress.org/Function_Reference/get_template_part) to load CPT specific pieces of code. For example (from the Codex): ``` get_template_part( 'nav', 'single' ); // Navigation bar to use in single pages (nav-single.php) ``` You can then reuse piece...
189,981
<p>I know that you can remove the following line from the WordPress source code:</p> <pre><code>&lt;meta name="generator" content="WordPress 4.2.2" /&gt; </code></pre> <p>But instead of removing the tag completely, I just want to change its value. Is there a way to achieve that?</p>
[ { "answer_id": 189987, "author": "Mayeenul Islam", "author_id": 22728, "author_profile": "https://wordpress.stackexchange.com/users/22728", "pm_score": 4, "selected": true, "text": "<p>Actually there is no hook there to change the texts on the fly. So the way is like below:</p>\n\n<p>Let...
2015/05/31
[ "https://wordpress.stackexchange.com/questions/189981", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70882/" ]
I know that you can remove the following line from the WordPress source code: ``` <meta name="generator" content="WordPress 4.2.2" /> ``` But instead of removing the tag completely, I just want to change its value. Is there a way to achieve that?
Actually there is no hook there to change the texts on the fly. So the way is like below: Let's first remove the default one, use the following code in `functions.php`: ``` remove_action( 'wp_head', 'wp_generator' ); ``` Now show our new one, add the following code in `functions.php`: ``` function wpse_custom_gene...
189,982
<p>Sorry if this question is trivial. I'm just beginning to develop plugins in WordPress. </p> <p>In all the tutorials I found this: while creating the custom tables, <code>$wpdb-&gt;prefix</code> is used.</p> <p>Example:</p> <pre><code>$table_name = $wpdb-&gt;prefix . "liveshoutbox"; </code></pre> <p>My question: ...
[ { "answer_id": 189983, "author": "sakibmoon", "author_id": 23214, "author_profile": "https://wordpress.stackexchange.com/users/23214", "pm_score": 6, "selected": true, "text": "<p>It is mandatory, though it is not enforced.</p>\n\n<p>Consider the scenario when two Wordpress site has been...
2015/05/31
[ "https://wordpress.stackexchange.com/questions/189982", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/66633/" ]
Sorry if this question is trivial. I'm just beginning to develop plugins in WordPress. In all the tutorials I found this: while creating the custom tables, `$wpdb->prefix` is used. Example: ``` $table_name = $wpdb->prefix . "liveshoutbox"; ``` My question: > > Is it mandatory to use `$wpdb->prefix`? What happe...
It is mandatory, though it is not enforced. Consider the scenario when two Wordpress site has been setup in the same database. One with prefix `wp_` and another with `wp2_`. If you install your plugin in both of the sites with the prefix, your created tables will be `wp_liveshoutbox` for first site and `wp2_liveshoutb...
189,985
<p>I made a parent theme and a child theme in one of my project. I enqueued CSS and JavaScripts in my parent theme like below:</p> <pre><code>function project_necessary_scripts() { //Stylesheets wp_register_style( 'bootstrap-css', get_template_directory_uri() .'/css/bootstrap.min.css' ); wp_register_style(...
[ { "answer_id": 189986, "author": "Mayeenul Islam", "author_id": 22728, "author_profile": "https://wordpress.stackexchange.com/users/22728", "pm_score": 6, "selected": true, "text": "<p>You are very nearer to the solution, because you are on the right path. Just to tweak a little bit:</p>...
2015/05/31
[ "https://wordpress.stackexchange.com/questions/189985", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22728/" ]
I made a parent theme and a child theme in one of my project. I enqueued CSS and JavaScripts in my parent theme like below: ``` function project_necessary_scripts() { //Stylesheets wp_register_style( 'bootstrap-css', get_template_directory_uri() .'/css/bootstrap.min.css' ); wp_register_style( 'bootstrap-ma...
You are very nearer to the solution, because you are on the right path. Just to tweak a little bit: There are two such action hooks: 1. [`wp_print_scripts`](https://codex.wordpress.org/Plugin_API/Action_Reference/wp_print_scripts), and 2. [`wp_print_styles`](https://codex.wordpress.org/Plugin_API/Action_Reference/wp_...
189,999
<p>I know I am not supposed to use query_posts</p> <p>The thing is I have a program that already do that.</p> <pre><code>query_posts(""); echo "is_search():" . is_search(); query_posts("s=kucing"); echo "is_search after():" . is_search(); </code></pre> <p>Now the first echo returns empty.</p> <p>The second returns ...
[ { "answer_id": 190001, "author": "sakibmoon", "author_id": 23214, "author_profile": "https://wordpress.stackexchange.com/users/23214", "pm_score": 2, "selected": false, "text": "<p>You can use <code>global $wp_query</code> and set the <code>is_search</code> to false;</p>\n\n<pre><code>gl...
2015/05/31
[ "https://wordpress.stackexchange.com/questions/189999", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73908/" ]
I know I am not supposed to use query\_posts The thing is I have a program that already do that. ``` query_posts(""); echo "is_search():" . is_search(); query_posts("s=kucing"); echo "is_search after():" . is_search(); ``` Now the first echo returns empty. The second returns 1 I wonder if there is some global var...
Your real big problem here **is** the use of `query_posts`. It breaks the main query object, and sets the main query object to the query made by `query_posts`. What you are seeing is quite normal. Your real solution here with the use of `query_posts` would be is to reset the main query back to what it should be. This...
190,000
<p>I noticed that if I don't explicitely enqueue my theme's main stylesheet and jQuery in my functions.php, these are loaded anyway. But perhaps it's better for some reason to enqueue them ? What is the right way of doing it ?</p>
[ { "answer_id": 190001, "author": "sakibmoon", "author_id": 23214, "author_profile": "https://wordpress.stackexchange.com/users/23214", "pm_score": 2, "selected": false, "text": "<p>You can use <code>global $wp_query</code> and set the <code>is_search</code> to false;</p>\n\n<pre><code>gl...
2015/05/31
[ "https://wordpress.stackexchange.com/questions/190000", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11634/" ]
I noticed that if I don't explicitely enqueue my theme's main stylesheet and jQuery in my functions.php, these are loaded anyway. But perhaps it's better for some reason to enqueue them ? What is the right way of doing it ?
Your real big problem here **is** the use of `query_posts`. It breaks the main query object, and sets the main query object to the query made by `query_posts`. What you are seeing is quite normal. Your real solution here with the use of `query_posts` would be is to reset the main query back to what it should be. This...
190,055
<p>I don't know where the mistake is. My code is not creating a table in WAMP:</p> <pre><code>function subscribe_table() { global $wpdb; $table_name = $wpdb-&gt;prefix.'_databasesubs'; $charset_collate = $wpdb-&gt;get_charset_collate(); if ( $wpdb-&gt;get_var( 'SHOW TABLES LIKE '. $table_name ) != $t...
[ { "answer_id": 190061, "author": "AddWeb Solution Pvt Ltd", "author_id": 73643, "author_profile": "https://wordpress.stackexchange.com/users/73643", "pm_score": 0, "selected": false, "text": "<p>Ramamoorthy,</p>\n\n<p>I reviewed your comment and there is no issue in code but check follow...
2015/06/01
[ "https://wordpress.stackexchange.com/questions/190055", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73934/" ]
I don't know where the mistake is. My code is not creating a table in WAMP: ``` function subscribe_table() { global $wpdb; $table_name = $wpdb->prefix.'_databasesubs'; $charset_collate = $wpdb->get_charset_collate(); if ( $wpdb->get_var( 'SHOW TABLES LIKE '. $table_name ) != $table_name ) { ...
Try edit Privileges for your wordpress database user from phpMyAdmin. ![enter image description here](https://i.stack.imgur.com/bhMGY.png)
190,062
<p>I know you can easily display custom content if a certain logged in user is a certain role using </p> <pre><code>&lt;?php if ( current_user_can('contributor') ) : ?&gt; media files loop &lt;?php endif; ?&gt; </code></pre> <p>However, I want to do the same thing, but for a specific username, not the logged in u...
[ { "answer_id": 190066, "author": "Sebas", "author_id": 73266, "author_profile": "https://wordpress.stackexchange.com/users/73266", "pm_score": 0, "selected": false, "text": "<p>are you trying to check the \"username\"? if so:</p>\n\n<pre><code>&lt;?php \n$user = wp_get_current_user();\n$...
2015/06/01
[ "https://wordpress.stackexchange.com/questions/190062", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70950/" ]
I know you can easily display custom content if a certain logged in user is a certain role using ``` <?php if ( current_user_can('contributor') ) : ?> media files loop <?php endif; ?> ``` However, I want to do the same thing, but for a specific username, not the logged in user. I have user profiles in my wordp...
Chris Haugen, You need to check user role who have 'artist' role and then you need to act on some video loop stuff. Here's the solution: ``` $user = get_user_by('login', $username ); if ( !empty( $user->roles ) && is_array( $user->roles ) ) { foreach ( $user->roles as $role ){ if($r...
190,091
<p>Added a custom font as follows</p> <ol> <li><p>Uploaded web-font files and given them the 777 permission</p> <p><code>http://example.com/wp-content/themes/mytheme/css/fonts/</code></p></li> <li><p>Added rules to the css file </p> <p><code>@font-face { font-family: 'museo_sans700'; src: url('http://example...
[ { "answer_id": 190092, "author": "sohan", "author_id": 69017, "author_profile": "https://wordpress.stackexchange.com/users/69017", "pm_score": 0, "selected": false, "text": "<p>404 stands for file are not available at the URL you are trying to access it. check your file path and files in...
2015/06/01
[ "https://wordpress.stackexchange.com/questions/190091", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54871/" ]
Added a custom font as follows 1. Uploaded web-font files and given them the 777 permission `http://example.com/wp-content/themes/mytheme/css/fonts/` 2. Added rules to the css file `@font-face { font-family: 'museo_sans700'; src: url('http://example.com/wp-content/themes/mytheme/css/fonts/museosans_700-webfont.eo...
Please use short path file url rather then absolute path. So code is like: ``` @font-face{ /* for IE */ font-family:FontFamily; src:url(Font.eot); } @font-face { /* for non-IE */ font-family:FontFamily; src:url(http://) format("No-IE-404"),url(Font.ttf) format("truetype"); } ``` Make sure that readable web has rele...
190,094
<p>Is possible to create a child theme using various parents themes as template, instead of only a single parent?</p> <p><strong>Example:</strong> The child theme will be called 'Light', and his parents will be the theme 'Sky', the theme 'Color' and the theme 'Star'. It's possible call these three other themes in stan...
[ { "answer_id": 190092, "author": "sohan", "author_id": 69017, "author_profile": "https://wordpress.stackexchange.com/users/69017", "pm_score": 0, "selected": false, "text": "<p>404 stands for file are not available at the URL you are trying to access it. check your file path and files in...
2015/06/01
[ "https://wordpress.stackexchange.com/questions/190094", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63486/" ]
Is possible to create a child theme using various parents themes as template, instead of only a single parent? **Example:** The child theme will be called 'Light', and his parents will be the theme 'Sky', the theme 'Color' and the theme 'Star'. It's possible call these three other themes in standard way to be the core...
Please use short path file url rather then absolute path. So code is like: ``` @font-face{ /* for IE */ font-family:FontFamily; src:url(Font.eot); } @font-face { /* for non-IE */ font-family:FontFamily; src:url(http://) format("No-IE-404"),url(Font.ttf) format("truetype"); } ``` Make sure that readable web has rele...
190,122
<p>Got my brain scratching round a wee issue here.</p> <p>In short... </p> <ol> <li><p>If home page, then do nothing</p></li> <li><p>if page has a thumbnail then run code that pops the page title on top of full width thumbnail with suitable CSS</p></li> <li><p>If no thumbnail then show normal entry title</p></li> </o...
[ { "answer_id": 190123, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 2, "selected": false, "text": "<p>Write it out in english and be clear about your logic, aka if you say that X should happen when Y is true, w...
2015/06/01
[ "https://wordpress.stackexchange.com/questions/190122", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73976/" ]
Got my brain scratching round a wee issue here. In short... 1. If home page, then do nothing 2. if page has a thumbnail then run code that pops the page title on top of full width thumbnail with suitable CSS 3. If no thumbnail then show normal entry title Got so far but no further. Any help would be greatly appreci...
If I understood you correctly: ``` <?php //if home, do nothing if( ! is_home() || ! front_page() ) { //if has post thumbnail if( has_post_thumbnail() ) { the_post_thumbnail( 'full' ); echo '<h1 class="entry-title">'. get_the_title() .'</h1>'; } else { //no post thum...
190,147
<p>I can't figure out why the media uploader doesn't show. I'm trying to do a media upload window so the user can upload a file. The problem is, when I click on the Upload button, nothing happens, the window is not shown and I don't know why. I think it has something to do that the submenu in which I want to add the up...
[ { "answer_id": 190168, "author": "dea", "author_id": 73049, "author_profile": "https://wordpress.stackexchange.com/users/73049", "pm_score": 2, "selected": false, "text": "<p>I couldn't find what was wrong with the code, so I used a different code which I found on the internet and now th...
2015/06/01
[ "https://wordpress.stackexchange.com/questions/190147", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73049/" ]
I can't figure out why the media uploader doesn't show. I'm trying to do a media upload window so the user can upload a file. The problem is, when I click on the Upload button, nothing happens, the window is not shown and I don't know why. I think it has something to do that the submenu in which I want to add the uploa...
I couldn't find what was wrong with the code, so I used a different code which I found on the internet and now the window is opening. ``` var file_frame; $('#csv_file_button').on('click', function(event){ event.preventDefault(); if ( file_frame ) { file_frame.open(); return; } // Create the media fr...
190,170
<p>I am trying to remove background and header from appearance menu, but they don't seem to go away! I think it's because I have activated customize, but can I remove them anyway without using CSS or JS?</p> <p>Here is my code:</p> <pre><code>add_action('admin_menu', 'remove_unnecessary_wordpress_menus', 999); funct...
[ { "answer_id": 190175, "author": "James Cushing", "author_id": 67327, "author_profile": "https://wordpress.stackexchange.com/users/67327", "pm_score": 3, "selected": true, "text": "<p>As overcomplicated as it sounds, I always find the best way to handle admin menu modifications is to ove...
2015/06/02
[ "https://wordpress.stackexchange.com/questions/190170", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74011/" ]
I am trying to remove background and header from appearance menu, but they don't seem to go away! I think it's because I have activated customize, but can I remove them anyway without using CSS or JS? Here is my code: ``` add_action('admin_menu', 'remove_unnecessary_wordpress_menus', 999); function remove_unnecessar...
As overcomplicated as it sounds, I always find the best way to handle admin menu modifications is to overlook the given wordpress `remove_` functions and go straight to the `$menu` and `$submenu` globals. In the case you've specified here, you'd want to change your code to: ``` add_action('admin_menu', 'remove_unneces...
190,194
<p>I want to use Wordpress multisite with subdomain and directory simultaneously like</p> <pre>http://site1.wp.com http://site2.wp.com http://wp.com/site3</pre> <p>All of the sub sites will be using same database and code. Is there any way to use subdomain and directory at the same time?</p>
[ { "answer_id": 190216, "author": "Jan Beck", "author_id": 18760, "author_profile": "https://wordpress.stackexchange.com/users/18760", "pm_score": 1, "selected": false, "text": "<p>It can be done, I'm actually using it for my private multisite installation.</p>\n\n<ol>\n<li>Install WP mul...
2015/06/02
[ "https://wordpress.stackexchange.com/questions/190194", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74028/" ]
I want to use Wordpress multisite with subdomain and directory simultaneously like ``` http://site1.wp.com http://site2.wp.com http://wp.com/site3 ``` All of the sub sites will be using same database and code. Is there any way to use subdomain and directory at the same time?
It can be done, I'm actually using it for my private multisite installation. 1. Install WP multisite and set it up in "subdirectory-mode" 2. Install and setup the [Domain Mapping plugin](https://premium.wpmudev.org/project/domain-mapping/) by WPMU 3. Create a subdomain and point it to your installation. Add this subdo...
190,242
<p>I'm trying to fetch both the first_name and last_name of all users at the same time, using the wpdb-object and the wp_usermeta table. I can't seem to figure out how to get both in the same query. Below is what I've got so far.</p> <pre><code>global $wpdb; $ansatte = $wpdb-&gt;get_results("SELECT user_id, meta_v...
[ { "answer_id": 190244, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 4, "selected": true, "text": "<p>I can't find a clean, native way to pull this data. There are a couple of ways I can think of to do this: Fir...
2015/06/02
[ "https://wordpress.stackexchange.com/questions/190242", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/68915/" ]
I'm trying to fetch both the first\_name and last\_name of all users at the same time, using the wpdb-object and the wp\_usermeta table. I can't seem to figure out how to get both in the same query. Below is what I've got so far. ``` global $wpdb; $ansatte = $wpdb->get_results("SELECT user_id, meta_value AS first_...
I can't find a clean, native way to pull this data. There are a couple of ways I can think of to do this: First, something like: ``` $sql = " SELECT user_id,meta_key,meta_value FROM {$wpdb->usermeta} WHERE ({$wpdb->usermeta}.meta_key = 'first_name' OR {$wpdb->usermeta}.meta_key = 'last_name')"; $ansatte = $wpdb...
190,248
<p>I want to to get the Author name of the Parent theme.</p> <p>I can get the theme name using wp_get_theme() to get the theme object of the current (child) theme. From this I can get the parent theme name. </p> <p>Next I think I need to get the object of the parent theme, but unsure how best to approach this. Here i...
[ { "answer_id": 190285, "author": "JediTricks007", "author_id": 49017, "author_profile": "https://wordpress.stackexchange.com/users/49017", "pm_score": 0, "selected": false, "text": "<p>This works for me.</p>\n\n<pre><code> &lt;?php\n $my_theme = wp_get_theme('parentThemeName');\n echo...
2015/06/02
[ "https://wordpress.stackexchange.com/questions/190248", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38077/" ]
I want to to get the Author name of the Parent theme. I can get the theme name using wp\_get\_theme() to get the theme object of the current (child) theme. From this I can get the parent theme name. Next I think I need to get the object of the parent theme, but unsure how best to approach this. Here is my code so fa...
Thanks for all the help which pointed me in the right direction. In the end I used the following: ``` $style_parent_theme = wp_get_theme(get_template()); $style_parent_theme_author = $style_parent_theme->get( 'Author' ); ``` I use get\_template() to recover the folder name of the parent theme. wp\_get\_theme then g...
190,254
<p>I have to write my own MySQL query since I haven't found a good way to do it within wordpress functionality.</p> <p>I want the search query to search trough post_title / post_content &amp; meta_key description in pages &amp; CPT transit_routes it also need to get those results in a specific language (copied filter ...
[ { "answer_id": 190258, "author": "shanebp", "author_id": 16575, "author_profile": "https://wordpress.stackexchange.com/users/16575", "pm_score": 0, "selected": false, "text": "<p>I believe you need to setup the post data for each post.\nTry: </p>\n\n<pre><code>$search_result = search_que...
2015/06/02
[ "https://wordpress.stackexchange.com/questions/190254", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10501/" ]
I have to write my own MySQL query since I haven't found a good way to do it within wordpress functionality. I want the search query to search trough post\_title / post\_content & meta\_key description in pages & CPT transit\_routes it also need to get those results in a specific language (copied filter from WPML) the...
I got it ! Here is my final code for people who will search for similar problem :) in functions.php : ``` function se190254_custom_sql_for_search( ) { global $wpdb; //For security escape the search parameter $search_string = esc_sql($_GET['s']); //Build the SQL request with $wpdb->base_prefix for "p...
190,259
<p>I'm working on a client's fresh install and server. Every time I attempt to save a post or page, I'm immediately sent a connection reset error (<code>This webpage is not available - ERR_CONNECTION_RESET</code>). <code>admin-ajax.php</code> is also triggering a connection reset when autosaving drafts.</p> <p>This in...
[ { "answer_id": 190258, "author": "shanebp", "author_id": 16575, "author_profile": "https://wordpress.stackexchange.com/users/16575", "pm_score": 0, "selected": false, "text": "<p>I believe you need to setup the post data for each post.\nTry: </p>\n\n<pre><code>$search_result = search_que...
2015/06/02
[ "https://wordpress.stackexchange.com/questions/190259", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24582/" ]
I'm working on a client's fresh install and server. Every time I attempt to save a post or page, I'm immediately sent a connection reset error (`This webpage is not available - ERR_CONNECTION_RESET`). `admin-ajax.php` is also triggering a connection reset when autosaving drafts. This install is unremarkable (WP 4.2.2,...
I got it ! Here is my final code for people who will search for similar problem :) in functions.php : ``` function se190254_custom_sql_for_search( ) { global $wpdb; //For security escape the search parameter $search_string = esc_sql($_GET['s']); //Build the SQL request with $wpdb->base_prefix for "p...
190,261
<p>This may be a 'noob' question, but...</p> <p>It doesn't seem possible to modify the WP-Login page via PHP (eg. add the get_header() code or new DIVs) to match the site theme. That is, without hacking the core, of course. (If there -is- a way to do this, please let me know!) And -yes- I am aware you can create a log...
[ { "answer_id": 190258, "author": "shanebp", "author_id": 16575, "author_profile": "https://wordpress.stackexchange.com/users/16575", "pm_score": 0, "selected": false, "text": "<p>I believe you need to setup the post data for each post.\nTry: </p>\n\n<pre><code>$search_result = search_que...
2015/06/02
[ "https://wordpress.stackexchange.com/questions/190261", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17248/" ]
This may be a 'noob' question, but... It doesn't seem possible to modify the WP-Login page via PHP (eg. add the get\_header() code or new DIVs) to match the site theme. That is, without hacking the core, of course. (If there -is- a way to do this, please let me know!) And -yes- I am aware you can create a login templa...
I got it ! Here is my final code for people who will search for similar problem :) in functions.php : ``` function se190254_custom_sql_for_search( ) { global $wpdb; //For security escape the search parameter $search_string = esc_sql($_GET['s']); //Build the SQL request with $wpdb->base_prefix for "p...
190,264
<p>I would like to display my categories with a thumbnail in woocommerce. I am able to list the child terms as a link but i would like to add additional content. I have added the code below in which I use to display the child terms for "product_cat" as a link on my template home-page.php. But I would also like to add ...
[ { "answer_id": 192643, "author": "Domain", "author_id": 26523, "author_profile": "https://wordpress.stackexchange.com/users/26523", "pm_score": 3, "selected": true, "text": "<p>Have did some customization. This will help you show parent and child category images. You can later customize ...
2015/06/02
[ "https://wordpress.stackexchange.com/questions/190264", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/67512/" ]
I would like to display my categories with a thumbnail in woocommerce. I am able to list the child terms as a link but i would like to add additional content. I have added the code below in which I use to display the child terms for "product\_cat" as a link on my template home-page.php. But I would also like to add the...
Have did some customization. This will help you show parent and child category images. You can later customize this code as per your requirements. ``` $taxonomyName = "product_cat"; //This gets top layer terms only. This is done by setting parent to 0. $parent_terms = get_terms($taxonomyName, array('parent'...
190,286
<p>I am trying to switch my current custom theme to <code>twenty fifteen</code> theme if the visitor is admin. So I put following code into my <code>custom theme functions.php</code></p> <pre><code>/*** Switching theme to Admin ***/ add_action( 'setup_theme', 'switch_user_theme' ); function switch_user_theme() { i...
[ { "answer_id": 190288, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 3, "selected": true, "text": "<p>You are sort of doing this in a roundabout way. WordPress has a function called <a href=\"https://codex.wordp...
2015/06/03
[ "https://wordpress.stackexchange.com/questions/190286", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43764/" ]
I am trying to switch my current custom theme to `twenty fifteen` theme if the visitor is admin. So I put following code into my `custom theme functions.php` ``` /*** Switching theme to Admin ***/ add_action( 'setup_theme', 'switch_user_theme' ); function switch_user_theme() { if ( current_user_can( 'manage_option...
You are sort of doing this in a roundabout way. WordPress has a function called [`switch_theme()`](https://codex.wordpress.org/Function_Reference/switch_theme): ``` add_action( 'setup_theme', 'switch_user_theme' ); function switch_user_theme() { if ( current_user_can( 'manage_options' ) ) { switch_theme('twentyt...
190,297
<p>I am trying to create a ajaxform on the front side. I am using the code</p> <pre><code> jQuery.ajax( { type: "post", dataType: "json", url: ajaxurl, data: formData, success: function(msg){ console.log(msg); } ...
[ { "answer_id": 190299, "author": "Krzysiek Dróżdż", "author_id": 34172, "author_profile": "https://wordpress.stackexchange.com/users/34172", "pm_score": 7, "selected": true, "text": "<p>In backend there is global <code>ajaxurl</code> variable defined by WordPress itself.</p>\n\n<p>This v...
2015/06/03
[ "https://wordpress.stackexchange.com/questions/190297", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74079/" ]
I am trying to create a ajaxform on the front side. I am using the code ``` jQuery.ajax( { type: "post", dataType: "json", url: ajaxurl, data: formData, success: function(msg){ console.log(msg); } }); ``` for ...
In backend there is global `ajaxurl` variable defined by WordPress itself. This variable is not created by WP in frontend. It means that if you want to use AJAX calls in frontend, then you have to define such variable by yourself. Good way to do this is to use `wp_localize_script`. Let's assume your AJAX calls are i...
190,303
<p>I am implementing a section in my website to get the top 5 authors using this code.</p> <pre><code>function ranked_authors(){ $usrs = get_users('role=contributor'); $countarr = array(); foreach ($usrs as $usr) { $post_views = total_no_of_post_views($usr-&gt;ID); $countarr[$usr-&gt;ID] = $post_views...
[ { "answer_id": 190319, "author": "Syed", "author_id": 24599, "author_profile": "https://wordpress.stackexchange.com/users/24599", "pm_score": 1, "selected": false, "text": "<p>I am not sure what approach you are using to send ajax request, but if you are using WordPress standard code for...
2015/06/03
[ "https://wordpress.stackexchange.com/questions/190303", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/56650/" ]
I am implementing a section in my website to get the top 5 authors using this code. ``` function ranked_authors(){ $usrs = get_users('role=contributor'); $countarr = array(); foreach ($usrs as $usr) { $post_views = total_no_of_post_views($usr->ID); $countarr[$usr->ID] = $post_views; } arsort($cou...
You need a custom query - this will join the posts, postmeta and usermeta table together and then count all `communityposts`, `post` and `video` views, grouped by author: ``` function wpse_190303_get_popular_users( $number = 5 ) { if ( ! $number = absint( $number ) ) return; global $wpdb; $query ...
190,328
<p>I have a custom database table within wordpress database.. I filled this database with data and wordpress posts table with matching ids</p> <p>an example would be...</p> <p><strong>wp-posts table has</strong></p> <pre><code> id - title 1 - record1 title 2 - record2 title </code></pre> <p><strong>cus...
[ { "answer_id": 190369, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 0, "selected": false, "text": "<p>There are filters in <a href=\"https://codex.wordpress.org/Function_Reference/get_metadata#Notes\" rel=\"nof...
2015/06/03
[ "https://wordpress.stackexchange.com/questions/190328", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62148/" ]
I have a custom database table within wordpress database.. I filled this database with data and wordpress posts table with matching ids an example would be... **wp-posts table has** ``` id - title 1 - record1 title 2 - record2 title ``` **custom table has** ``` id - title - data1 - data...
After long searches and tries I ended up with **"Pods Framework"**. It gives me a choice to store my custom field values to a custom table within wordpress database. Now i am able to query them with other sources (such as other web apps that shares the same database).
190,335
<p>I know there is a possibility to change the structure/design of the product page by editing the file <code>single-product-php</code> - in a child-theme.</p> <p>The changes made of that file will affect all the product pages. </p> <p>But how do I change the template file for specific product pages? Like I can with ...
[ { "answer_id": 190342, "author": "sohan", "author_id": 69017, "author_profile": "https://wordpress.stackexchange.com/users/69017", "pm_score": 2, "selected": false, "text": "<p>You need to check WordPress <a href=\"https://developer.wordpress.org/themes/basics/template-hierarchy/\" rel=\...
2015/06/03
[ "https://wordpress.stackexchange.com/questions/190335", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54836/" ]
I know there is a possibility to change the structure/design of the product page by editing the file `single-product-php` - in a child-theme. The changes made of that file will affect all the product pages. But how do I change the template file for specific product pages? Like I can with a custom page template? From...
Woo Commerce is off topic as its a plugin and not specifically related to WordPress but what you can do is copy over the single-product.php template to a WooCommerce folder in your child theme. change the file name and modify the file, then use [`single_template`](https://codex.wordpress.org/Plugin_API/Filter_Reference...
190,344
<p>I have a Wordpress child-themed site at <a href="http://mrme.me/utahcountyhiking" rel="nofollow noreferrer">http://mrme.me/utahcountyhiking</a>, and I'm trying to get it so that when you click on the featured image it goes to the associated post. Right now it goes to the media page for the featured image instead of ...
[ { "answer_id": 190360, "author": "Brad Dalton", "author_id": 9884, "author_profile": "https://wordpress.stackexchange.com/users/9884", "pm_score": 3, "selected": true, "text": "<p>Theme customisation is off topic however the default themes are exempt so lets look at an example of how its...
2015/06/03
[ "https://wordpress.stackexchange.com/questions/190344", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73963/" ]
I have a Wordpress child-themed site at <http://mrme.me/utahcountyhiking>, and I'm trying to get it so that when you click on the featured image it goes to the associated post. Right now it goes to the media page for the featured image instead of the post. What I've tried * I figured out how to get the child theme to...
Theme customisation is off topic however the default themes are exempt so lets look at an example of how its done in Twenty Fifteen. ``` if ( ! function_exists( 'twentyfifteen_post_thumbnail' ) ) : function twentyfifteen_post_thumbnail() { if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ...
190,357
<p>Hi I have a simple website that displays every post title in a list, I'm trying to change the active post title to be different when its being viewed. I have tried this but it's not working.</p> <pre><code>&lt;ul class="students"&gt; &lt;?php $IDOutsideLoop = $post-&gt;ID; global $post; $myposts = wp_get_arch...
[ { "answer_id": 190358, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 2, "selected": true, "text": "<p>Your current code relies on time travel to work:</p>\n\n<pre><code>$IDOutsideLoop = $post-&gt;ID;\nglobal $po...
2015/06/03
[ "https://wordpress.stackexchange.com/questions/190357", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/67730/" ]
Hi I have a simple website that displays every post title in a list, I'm trying to change the active post title to be different when its being viewed. I have tried this but it's not working. ``` <ul class="students"> <?php $IDOutsideLoop = $post->ID; global $post; $myposts = wp_get_archives('type=alpha'); forea...
Your current code relies on time travel to work: ``` $IDOutsideLoop = $post->ID; global $post; ``` Specifically the first line is peering into the future, how can it know what `$post->ID` is if it's undeclared? The fix is `global $post;`, but when the computer gets to that line, it's too late ``` global $post; $IDO...
190,359
<p>Well I should qualify that title. The shortcode is fine in itself, and no doubt nothing to do with the guys at CF7 causing this issue. I am sure it's me, but it just isn't working after I've added another shortcode directly after it. Here's the story:</p> <p>I have a page which should appear with some text to non l...
[ { "answer_id": 190364, "author": "gdaniel", "author_id": 30984, "author_profile": "https://wordpress.stackexchange.com/users/30984", "pm_score": 1, "selected": false, "text": "<p>From the <a href=\"http://codex.wordpress.org/Shortcode_API\" rel=\"nofollow\">codex</a>: </p>\n\n<blockquote...
2015/06/03
[ "https://wordpress.stackexchange.com/questions/190359", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74104/" ]
Well I should qualify that title. The shortcode is fine in itself, and no doubt nothing to do with the guys at CF7 causing this issue. I am sure it's me, but it just isn't working after I've added another shortcode directly after it. Here's the story: I have a page which should appear with some text to non logged-in u...
From the [codex](http://codex.wordpress.org/Shortcode_API): > > The shortcode parser uses a single pass on the post content. This > means that if the $content parameter of a shortcode handler contains > another shortcode, it won't be parsed. > <http://codex.wordpress.org/Shortcode_API> > > > The codex also pr...
190,381
<p>I am trying to write a plugin that copies a custom post type "event" from one blog to another. The code for copying I already have working but I cannot seem to get this "add_action" hook to work when an event is published.</p> <pre><code>add_action('publish_event', 'copy_event_to_mini_site' ); function copy_event_...
[ { "answer_id": 264381, "author": "Syndyloo", "author_id": 118138, "author_profile": "https://wordpress.stackexchange.com/users/118138", "pm_score": 3, "selected": false, "text": "<p>Read the codex, that's where i finally found the answer :</p>\n\n<p><a href=\"https://codex.wordpress.org/...
2015/06/03
[ "https://wordpress.stackexchange.com/questions/190381", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/69258/" ]
I am trying to write a plugin that copies a custom post type "event" from one blog to another. The code for copying I already have working but I cannot seem to get this "add\_action" hook to work when an event is published. ``` add_action('publish_event', 'copy_event_to_mini_site' ); function copy_event_to_mini_site(...
Read the codex, that's where i finally found the answer : <https://codex.wordpress.org/Plugin_API/Action_Reference/publish_post> in the end : **Custom Post Types** To trigger this action for a custom post type, use publish\_{$custom\_post\_type}. e.g. if your post type is 'book' use: ``` add_action( 'publish_book'...
190,395
<p>I'm developing a new theme and plugins for it. Unfortunately, the comment reply link is broken. Instead of moving the comment reply textarea, the page is reloaded by adding e.g. ?replytocom=2#respond to the URL (corresponding to the value of the href attribute).</p> <p><s>Here's a link to see what I mean: ...</s> (...
[ { "answer_id": 264381, "author": "Syndyloo", "author_id": 118138, "author_profile": "https://wordpress.stackexchange.com/users/118138", "pm_score": 3, "selected": false, "text": "<p>Read the codex, that's where i finally found the answer :</p>\n\n<p><a href=\"https://codex.wordpress.org/...
2015/06/03
[ "https://wordpress.stackexchange.com/questions/190395", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40934/" ]
I'm developing a new theme and plugins for it. Unfortunately, the comment reply link is broken. Instead of moving the comment reply textarea, the page is reloaded by adding e.g. ?replytocom=2#respond to the URL (corresponding to the value of the href attribute). ~~Here's a link to see what I mean: ...~~ (No longer nec...
Read the codex, that's where i finally found the answer : <https://codex.wordpress.org/Plugin_API/Action_Reference/publish_post> in the end : **Custom Post Types** To trigger this action for a custom post type, use publish\_{$custom\_post\_type}. e.g. if your post type is 'book' use: ``` add_action( 'publish_book'...
190,408
<p>I bought a WP-Theme which defines a custom image-size in his theme-functions.php like this:</p> <pre><code>if ( function_exists( 'add_image_size' ) ){ add_image_size( 'tie-small', 70, 70, true ); } </code></pre> <p>As you can see the third-parameter is true, which results in hard crop mode (see <a href="https:...
[ { "answer_id": 190419, "author": "Benito Lopez", "author_id": 73915, "author_profile": "https://wordpress.stackexchange.com/users/73915", "pm_score": 1, "selected": false, "text": "<p>Change the action to 'init':</p>\n\n<pre><code>class My_Plugin {\n public function __construct() {\n ...
2015/06/03
[ "https://wordpress.stackexchange.com/questions/190408", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65411/" ]
I bought a WP-Theme which defines a custom image-size in his theme-functions.php like this: ``` if ( function_exists( 'add_image_size' ) ){ add_image_size( 'tie-small', 70, 70, true ); } ``` As you can see the third-parameter is true, which results in hard crop mode (see [Wordpress Documentation for add\_image\_...
Change the action to 'init': ``` class My_Plugin { public function __construct() { add_action( 'init', array( $this, 'overwrite_wptheme_settings' ) ); } public function overwrite_wptheme_settings() { add_image_size( 'tie-small', 70, 70, false ); } } ```
190,449
<p>I have installed the Beauty Contact Popup Form Wordpress Plugin on my website, and want to use the raw source code (or a better way to access the form) in a mysql_fetch_array loop like this:</p> <pre><code>&lt;?php // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $resul...
[ { "answer_id": 190419, "author": "Benito Lopez", "author_id": 73915, "author_profile": "https://wordpress.stackexchange.com/users/73915", "pm_score": 1, "selected": false, "text": "<p>Change the action to 'init':</p>\n\n<pre><code>class My_Plugin {\n public function __construct() {\n ...
2015/06/04
[ "https://wordpress.stackexchange.com/questions/190449", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74151/" ]
I have installed the Beauty Contact Popup Form Wordpress Plugin on my website, and want to use the raw source code (or a better way to access the form) in a mysql\_fetch\_array loop like this: ``` <?php // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Prin...
Change the action to 'init': ``` class My_Plugin { public function __construct() { add_action( 'init', array( $this, 'overwrite_wptheme_settings' ) ); } public function overwrite_wptheme_settings() { add_image_size( 'tie-small', 70, 70, false ); } } ```
190,461
<p>I wrote a plugin in which one of the PHP files itself opens and writes another small text file.</p> <p>How to grant this PHP file the right permissions?</p>
[ { "answer_id": 190419, "author": "Benito Lopez", "author_id": 73915, "author_profile": "https://wordpress.stackexchange.com/users/73915", "pm_score": 1, "selected": false, "text": "<p>Change the action to 'init':</p>\n\n<pre><code>class My_Plugin {\n public function __construct() {\n ...
2015/06/04
[ "https://wordpress.stackexchange.com/questions/190461", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74155/" ]
I wrote a plugin in which one of the PHP files itself opens and writes another small text file. How to grant this PHP file the right permissions?
Change the action to 'init': ``` class My_Plugin { public function __construct() { add_action( 'init', array( $this, 'overwrite_wptheme_settings' ) ); } public function overwrite_wptheme_settings() { add_image_size( 'tie-small', 70, 70, false ); } } ```
190,465
<p>Quick simple question. How would I get the result of a rewrite in wordpress?</p> <p>For example I have:</p> <pre><code>www.some.website.com/some/parameter </code></pre> <p>How would I get the end result that WP processes? Aka, the</p> <pre><code>www.some.website.com/index.php?paramter1=some&amp;paramter2=paramet...
[ { "answer_id": 190501, "author": "ncwhitehead", "author_id": 74168, "author_profile": "https://wordpress.stackexchange.com/users/74168", "pm_score": 0, "selected": false, "text": "<p>Use the function get_query_var: <a href=\"http://codex.wordpress.org/Function_Reference/get_query_var\" r...
2015/06/04
[ "https://wordpress.stackexchange.com/questions/190465", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/67005/" ]
Quick simple question. How would I get the result of a rewrite in wordpress? For example I have: ``` www.some.website.com/some/parameter ``` How would I get the end result that WP processes? Aka, the ``` www.some.website.com/index.php?paramter1=some&paramter2=parameter ``` Cheers
Have a look at the [Action Reference](http://codex.wordpress.org/Plugin_API/Action_Reference) to see generally how requests are processed. After all the loading and init stuff happens, the `parse_request` action runs when the request is matched against the rewrite rules, and an object is passed containing all the regis...
190,474
<p>I need to have the ability to have Sticky posts for each category. The simplest way to do this appeared to be to just create two loops on the page. This is what I wrote:</p> <pre><code>&lt;?php //Custom "sticky" loop $sticky_posts = new WP_Query(array( 'post__in' =&gt; get_option('sticky_posts') )); if ($stick...
[ { "answer_id": 190483, "author": "Django Reinhardt", "author_id": 4109, "author_profile": "https://wordpress.stackexchange.com/users/4109", "pm_score": 2, "selected": false, "text": "<p>The answer to both issues was pretty simple.</p>\n\n<ol>\n<li>Simply add an argument to WP_Query to li...
2015/06/04
[ "https://wordpress.stackexchange.com/questions/190474", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4109/" ]
I need to have the ability to have Sticky posts for each category. The simplest way to do this appeared to be to just create two loops on the page. This is what I wrote: ``` <?php //Custom "sticky" loop $sticky_posts = new WP_Query(array( 'post__in' => get_option('sticky_posts') )); if ($sticky_posts->have_posts(...
To make this more complete, here is what I have said in comments in reply to the question on hand > > Just to quickly explain, `WP_Query` fails catastrophically in some cases where empty arrays are passed to some of its parameters, instead of also returning an empty array as we should expect, `WP_Query` returns all p...
190,478
<p>Good Day Everyone,</p> <p>I am trying my New User Registration form Plugin on a live site, but the emails are not being sent.</p> <p>I save the new user using:</p> <pre><code> if (empty($errors)) { $myplugin_newuser = wp_insert_user(array( 'user_login' =&gt; $user_login, 'user_e...
[ { "answer_id": 190483, "author": "Django Reinhardt", "author_id": 4109, "author_profile": "https://wordpress.stackexchange.com/users/4109", "pm_score": 2, "selected": false, "text": "<p>The answer to both issues was pretty simple.</p>\n\n<ol>\n<li>Simply add an argument to WP_Query to li...
2015/06/04
[ "https://wordpress.stackexchange.com/questions/190478", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/66412/" ]
Good Day Everyone, I am trying my New User Registration form Plugin on a live site, but the emails are not being sent. I save the new user using: ``` if (empty($errors)) { $myplugin_newuser = wp_insert_user(array( 'user_login' => $user_login, 'user_email' => $user_email, ...
To make this more complete, here is what I have said in comments in reply to the question on hand > > Just to quickly explain, `WP_Query` fails catastrophically in some cases where empty arrays are passed to some of its parameters, instead of also returning an empty array as we should expect, `WP_Query` returns all p...
190,491
<p>dear I unable to understand of simple function call &amp; do_action function call.</p> <pre><code>do_action: </code></pre> <p>I hook function and I place this in my one template file for use in header template.</p> <pre><code>add_action('theme_document', 'run_this') function run_this() { &lt;!DOCTYPE html&gt; &lt...
[ { "answer_id": 190497, "author": "Howdy_McGee", "author_id": 7355, "author_profile": "https://wordpress.stackexchange.com/users/7355", "pm_score": 2, "selected": false, "text": "<p>The main benefit with hooks ( such as <code>add_action</code> ) is that they allow you to add additional lo...
2015/06/04
[ "https://wordpress.stackexchange.com/questions/190491", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63068/" ]
dear I unable to understand of simple function call & do\_action function call. ``` do_action: ``` I hook function and I place this in my one template file for use in header template. ``` add_action('theme_document', 'run_this') function run_this() { <!DOCTYPE html> <html class="no-js"> <head> } ``` then I call i...
The main benefit with hooks ( such as `add_action` ) is that they allow you to add additional logic very easily based on priority. The only way to achieve the same thing with a standalone function is to edit the function directly. You wouldn't want to do this in premium theme ( or core ) as any time there's an update y...
190,509
<p>I can't seem to find where to delete/comment the line that prints:</p> <p><code>&lt;link rel="alternate" type="application/rss+xml" title="[site title] [single title] RSS de los comentarios" href="[site_url]/post/[single title]/feed/" /&gt;</code></p> <p>I've seen that there's a few plugins for this, but I just w...
[ { "answer_id": 190521, "author": "Jon", "author_id": 14416, "author_profile": "https://wordpress.stackexchange.com/users/14416", "pm_score": -1, "selected": false, "text": "<p>look in header.php</p>\n\n<p>A trial an error way of finding it is to delete the whole php page, load your wordp...
2015/06/04
[ "https://wordpress.stackexchange.com/questions/190509", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3435/" ]
I can't seem to find where to delete/comment the line that prints: `<link rel="alternate" type="application/rss+xml" title="[site title] [single title] RSS de los comentarios" href="[site_url]/post/[single title]/feed/" />` I've seen that there's a few plugins for this, but I just want not to rint this line... If fo...
Things added by WordPress core can not be deleted or removed, or better said, shouldn't be modified directly. Instead, you can use any of the actions and filters. Specifically, to disable comments feeds, you can use this (note the priority parameter): ``` remove_action( 'wp_head', 'feed_links', 2 ); ``` The above c...
190,510
<p>Is there a way to add a TinyMCE editor to the taxonomy description field on the term editing pages? The solution here (<a href="https://wordpress.stackexchange.com/questions/15758/can-you-add-the-visual-editor-to-the-description-field-for-custom-taxonomies">Can you add the visual editor to the description field for ...
[ { "answer_id": 190854, "author": "Oleg Butuzov", "author_id": 14536, "author_profile": "https://wordpress.stackexchange.com/users/14536", "pm_score": 5, "selected": true, "text": "<p>You can use a <strong>{$taxonomy}_edit_form_fields</strong> action hook to add html to the term edit tabl...
2015/06/04
[ "https://wordpress.stackexchange.com/questions/190510", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9764/" ]
Is there a way to add a TinyMCE editor to the taxonomy description field on the term editing pages? The solution here ([Can you add the visual editor to the description field for custom taxonomies?](https://wordpress.stackexchange.com/questions/15758/can-you-add-the-visual-editor-to-the-description-field-for-custom-tax...
You can use a **{$taxonomy}\_edit\_form\_fields** action hook to add html to the term edit table. In that HTML you can remove description textarea and add tinymce editor ``` add_action("{$taxonomy}_edit_form_fields", 'add_form_fields_example', 10, 2); function add_form_fields_example($term, $taxonomy){ ?> <tr...
190,511
<p>I want to show only one latest post by each author and found this code that it working. However, it takes too long to load the page since I have over 100K authors and 100K posts in database. How can I optimize this code?</p> <pre><code>&lt;?php //Displaying latest post per author on front page function filter_w...
[ { "answer_id": 190854, "author": "Oleg Butuzov", "author_id": 14536, "author_profile": "https://wordpress.stackexchange.com/users/14536", "pm_score": 5, "selected": true, "text": "<p>You can use a <strong>{$taxonomy}_edit_form_fields</strong> action hook to add html to the term edit tabl...
2015/06/04
[ "https://wordpress.stackexchange.com/questions/190511", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74171/" ]
I want to show only one latest post by each author and found this code that it working. However, it takes too long to load the page since I have over 100K authors and 100K posts in database. How can I optimize this code? ``` <?php //Displaying latest post per author on front page function filter_where($where = '')...
You can use a **{$taxonomy}\_edit\_form\_fields** action hook to add html to the term edit table. In that HTML you can remove description textarea and add tinymce editor ``` add_action("{$taxonomy}_edit_form_fields", 'add_form_fields_example', 10, 2); function add_form_fields_example($term, $taxonomy){ ?> <tr...
190,515
<p>I'm developing a site that involves a lot of long posts I'd like to break up using the nextpage quicktag. On the first page there's a large splash photo in the header that I'd like to disappear on subsequent pages—so I need some way of testing if the user is on the first page. I did find this code:</p> <p><code>if ...
[ { "answer_id": 190854, "author": "Oleg Butuzov", "author_id": 14536, "author_profile": "https://wordpress.stackexchange.com/users/14536", "pm_score": 5, "selected": true, "text": "<p>You can use a <strong>{$taxonomy}_edit_form_fields</strong> action hook to add html to the term edit tabl...
2015/06/04
[ "https://wordpress.stackexchange.com/questions/190515", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73676/" ]
I'm developing a site that involves a lot of long posts I'd like to break up using the nextpage quicktag. On the first page there's a large splash photo in the header that I'd like to disappear on subsequent pages—so I need some way of testing if the user is on the first page. I did find this code: `if ( isset($wp_que...
You can use a **{$taxonomy}\_edit\_form\_fields** action hook to add html to the term edit table. In that HTML you can remove description textarea and add tinymce editor ``` add_action("{$taxonomy}_edit_form_fields", 'add_form_fields_example', 10, 2); function add_form_fields_example($term, $taxonomy){ ?> <tr...
190,529
<p>I uploaded a brand-new wp install to my host. I am able to access the admin, and all its settings just fine, but I get a 500 internal error on the front-end.</p> <p><strong>I have tried solving this issue by:</strong></p> <ul> <li>checking .htaccess</li> <li>checking wp-config.php</li> <li>checking for missing cor...
[ { "answer_id": 190603, "author": "gdaniel", "author_id": 30984, "author_profile": "https://wordpress.stackexchange.com/users/30984", "pm_score": 1, "selected": false, "text": "<p>My problem had to do with file permissions. Even though it looked like the permissions were correct, the inde...
2015/06/04
[ "https://wordpress.stackexchange.com/questions/190529", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/30984/" ]
I uploaded a brand-new wp install to my host. I am able to access the admin, and all its settings just fine, but I get a 500 internal error on the front-end. **I have tried solving this issue by:** * checking .htaccess * checking wp-config.php * checking for missing core files * doing a permalink reset * checking fil...
My problem had to do with file permissions. Even though it looked like the permissions were correct, the index.php in the root had the permission set to 644, instead of 664. Once I changed the permission the front-end loaded. It's a bit odd that of all files in the root, the index is the only one with the wrong permiss...
190,532
<p>I'm trying to use the plugin PrivateContent to limit access to certain pages/categories. I have a function (getAllowedCategories()) which reads PrivateContent access levels for the current user and outputs a list of category IDs which the user has access to. I'm trying to use this to build a foreach() loop that pass...
[ { "answer_id": 190549, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p>You are wrapping your parameters string in unnecessary layer of quotes:</p>\n\n<ul>\n<li><code>$parameters = \"'cat...
2015/06/04
[ "https://wordpress.stackexchange.com/questions/190532", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/52164/" ]
I'm trying to use the plugin PrivateContent to limit access to certain pages/categories. I have a function (getAllowedCategories()) which reads PrivateContent access levels for the current user and outputs a list of category IDs which the user has access to. I'm trying to use this to build a foreach() loop that passes ...
You are wrapping your parameters string in unnecessary layer of quotes: * `$parameters = "'category__in=1'";` — wrong * `$parameters = 'category__in=1';` — right It is usually preferable to use arrays for query arguments: * `$parameters = [ 'category__in' => 1 ];`
190,540
<p>I have a page that has a new template, and I want to set that new template with wp-cli.</p> <p>When I <code>wp post get &lt;id&gt;</code> I get an output like the following:</p> <pre><code>+-----------------------+---------------------+ | Field | Value | +-----------------------+-----...
[ { "answer_id": 190542, "author": "Mike Lyons", "author_id": 20884, "author_profile": "https://wordpress.stackexchange.com/users/20884", "pm_score": 3, "selected": true, "text": "<p>I found that in the <a href=\"http://wp-cli.org/commands/post/create/\" rel=\"nofollow\">documentation</a> ...
2015/06/04
[ "https://wordpress.stackexchange.com/questions/190540", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20884/" ]
I have a page that has a new template, and I want to set that new template with wp-cli. When I `wp post get <id>` I get an output like the following: ``` +-----------------------+---------------------+ | Field | Value | +-----------------------+---------------------+ | ID ...
I found that in the [documentation](http://wp-cli.org/commands/post/create/) for wp-cli it says > > `[--<field>=<value>]` Associative args for the new post. See > [wp\_insert\_post().](https://codex.wordpress.org/Function_Reference/wp_insert_post) > > > Which then subsequently shows: > > > ``` > 'page_templat...
190,554
<p>I'm stuck in an awful situation and I think it's because I've registered 5 post types but calling flash_rewrite_rules() function just once, so I have this question:</p> <p>Should I call flash_rewrite_rules() function after each registration of custom post type or just one call?</p> <p>And by the way, is it OK to h...
[ { "answer_id": 190657, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 1, "selected": false, "text": "<p>Your problem is that you are flushing the rewrite rules before the post types are registered. Your <code>afte...
2015/06/04
[ "https://wordpress.stackexchange.com/questions/190554", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74115/" ]
I'm stuck in an awful situation and I think it's because I've registered 5 post types but calling flash\_rewrite\_rules() function just once, so I have this question: Should I call flash\_rewrite\_rules() function after each registration of custom post type or just one call? And by the way, is it OK to have 10 custom...
Don't call `flush_rewrite_rules`. It's a super expensive call to make and slows everything down. Also the order matters, but the correct thing to do is register all your content types, then re-save permalinks in WP Admin, and then... nothing, you've done everything. Only flush permalinks when things have changed, not ...
190,559
<p>I am following this DIY code by GravityWiz but the author doesn't mention how to make the code work with 30 minutes, 1 hour, 2 hours, etc...? He only explains how to make it work with 24 hours - <a href="http://gravitywiz.com/better-limit-submission-per-time-period-by-user-or-ip/" rel="nofollow">http://gravitywiz.co...
[ { "answer_id": 190565, "author": "Dave from Gravity Wiz", "author_id": 50224, "author_profile": "https://wordpress.stackexchange.com/users/50224", "pm_score": 1, "selected": false, "text": "<p>I've updated the article with more detailed instructions on the time_period usage. For others h...
2015/06/05
[ "https://wordpress.stackexchange.com/questions/190559", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29189/" ]
I am following this DIY code by GravityWiz but the author doesn't mention how to make the code work with 30 minutes, 1 hour, 2 hours, etc...? He only explains how to make it work with 24 hours - <http://gravitywiz.com/better-limit-submission-per-time-period-by-user-or-ip/> When looking at the code here - <https://gist...
I've updated the article with more detailed instructions on the time\_period usage. For others having the same question here: > The period of time to which the limit applies. The default time period is one day. In any 24 hour period, if the user reaches the limit they will no longer be able to make new submissions. > ...
190,568
<p>I get this type of data using <code>print_r()</code></p> <pre><code> Array ( [0] =&gt; test [1] =&gt; raviradadiya.ommune-buyer@gmail.com [2] =&gt; 1.00 [3] =&gt; 21:16:36 Jun 04, 2015 PDT [4] =&gt; 9DS7592P74GMN ) </code></pre> <p>Now I want to add this data in my custom table but I cant.</p> <p>Here is my ...
[ { "answer_id": 190565, "author": "Dave from Gravity Wiz", "author_id": 50224, "author_profile": "https://wordpress.stackexchange.com/users/50224", "pm_score": 1, "selected": false, "text": "<p>I've updated the article with more detailed instructions on the time_period usage. For others h...
2015/06/05
[ "https://wordpress.stackexchange.com/questions/190568", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74198/" ]
I get this type of data using `print_r()` ``` Array ( [0] => test [1] => raviradadiya.ommune-buyer@gmail.com [2] => 1.00 [3] => 21:16:36 Jun 04, 2015 PDT [4] => 9DS7592P74GMN ) ``` Now I want to add this data in my custom table but I cant. Here is my code ``` if(!empty($_POST)) { $player_name = $_POS...
I've updated the article with more detailed instructions on the time\_period usage. For others having the same question here: > The period of time to which the limit applies. The default time period is one day. In any 24 hour period, if the user reaches the limit they will no longer be able to make new submissions. > ...
190,588
<p>I see that upon upgrades the .maintenance file is deleted, if present. Is it still a viable/correct way to put WP in maintenance mode? </p>
[ { "answer_id": 190590, "author": "gmazzap", "author_id": 35541, "author_profile": "https://wordpress.stackexchange.com/users/35541", "pm_score": 6, "selected": true, "text": "<p>Not really.</p>\n\n<p><code>.maintenance</code> is a temporary file, not viable if you want to put your site i...
2015/06/05
[ "https://wordpress.stackexchange.com/questions/190588", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10381/" ]
I see that upon upgrades the .maintenance file is deleted, if present. Is it still a viable/correct way to put WP in maintenance mode?
Not really. `.maintenance` is a temporary file, not viable if you want to put your site in maintenance mode for a long time. If you look at [source](https://github.com/WordPress/WordPress/blob/master/wp-includes/load.php#L162-L165) the maintenance mode is maintained only if `$upgrading` variable defined in the file i...
190,594
<p>I'm using this plugin (<a href="https://github.com/parisholley/wordpress-fantastic-elasticsearch" rel="nofollow">FantasticElasticSearch</a>) to index content when it's published. So far it was strightforward and an easy task but, now that I tried to index a flag saying if a post is sticky, I'm having trouble and it'...
[ { "answer_id": 190609, "author": "Pat J", "author_id": 16121, "author_profile": "https://wordpress.stackexchange.com/users/16121", "pm_score": 0, "selected": false, "text": "<p>If you're not in The Loop, you should pass an ID to <code>is_sticky()</code>:</p>\n\n<pre><code>static function...
2015/06/05
[ "https://wordpress.stackexchange.com/questions/190594", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74215/" ]
I'm using this plugin ([FantasticElasticSearch](https://github.com/parisholley/wordpress-fantastic-elasticsearch)) to index content when it's published. So far it was strightforward and an easy task but, now that I tried to index a flag saying if a post is sticky, I'm having trouble and it's being impossible. I'm chan...
As I said in the question post, I finally solved it by looking into the $\_POST global. There's a `$_POST['sticky']` field (valued as *'sticky'*) that is there just when a Post is *sticky* or is being made *sticky*, and it's not when a post is not *sticky* or is being *unsticked*.
190,616
<p>We've turned on WordPress Auto-Updates (yey!), but, just in case this does break anything, we'd like to only run Auto-Updates during daylight hours (e.g. 09:00 - 17:30).</p> <p>We have the "on init" WP-Cron disabled, and are calling it from the servers crontab every 10 minutes.</p> <p>How can adapt the AutoUpdate,...
[ { "answer_id": 191018, "author": "Ben Cole", "author_id": 32532, "author_profile": "https://wordpress.stackexchange.com/users/32532", "pm_score": 3, "selected": false, "text": "<p>This one is actually surprisingly simple; add this to your wp-config.php file and all automatic updates will...
2015/06/05
[ "https://wordpress.stackexchange.com/questions/190616", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74235/" ]
We've turned on WordPress Auto-Updates (yey!), but, just in case this does break anything, we'd like to only run Auto-Updates during daylight hours (e.g. 09:00 - 17:30). We have the "on init" WP-Cron disabled, and are calling it from the servers crontab every 10 minutes. How can adapt the AutoUpdate, so all updates a...
This one is actually surprisingly simple; add this to your wp-config.php file and all automatic updates will be blocked when outside of the specified hours: ``` // Suspend updates when outside of business hours, 9:00 AM to 5:30 PM $updates_suspended = (date('Hi') < 0900 || date('Hi') > 1730); define( 'AUTOMATIC_UPDAT...
190,618
<p>I am trying to get rid of the following error in debug:</p> <pre><code>Notice: register_sidebar was called &lt;strong&gt;incorrectly&lt;/strong&gt;. No &lt;code&gt;id&lt;/code&gt; was set in the arguments array for the "Header" sidebar. </code></pre> <p>So when I register that sidebar I added the id parameter lik...
[ { "answer_id": 190622, "author": "shanebp", "author_id": 16575, "author_profile": "https://wordpress.stackexchange.com/users/16575", "pm_score": -1, "selected": false, "text": "<p>Try starting the <code>id</code> field value with 'sidebar'.</p>\n\n<p>If that doesn't work, the order shoul...
2015/06/05
[ "https://wordpress.stackexchange.com/questions/190618", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23259/" ]
I am trying to get rid of the following error in debug: ``` Notice: register_sidebar was called <strong>incorrectly</strong>. No <code>id</code> was set in the arguments array for the "Header" sidebar. ``` So when I register that sidebar I added the id parameter like so: ``` register_sidebar(array( 'id' => 'he...
Your code works when I test it. I can only assume that the registration code is being hooked into the system too early or too late. [`register_sidebar()` should be hooked on `widgets_init` per the Codex](https://codex.wordpress.org/Function_Reference/register_sidebar). Therefore: ``` function register_header_sidebar_w...
190,625
<p>How do I gee the numbered pagination of custom wpdb result? </p> <p>below code will show one latest post from each authors in the site. I want to show 20 posts per page with a numbered pagination.</p> <pre><code>$postids = $wpdb-&gt;get_results( " SELECT a.ID, a.post_title, a.post_author, a.post_date ...
[ { "answer_id": 190632, "author": "Ohsik", "author_id": 74171, "author_profile": "https://wordpress.stackexchange.com/users/74171", "pm_score": 2, "selected": false, "text": "<p>So I ended getting what I wanted to do with below code. However, I know this is not a good way to do this. Plea...
2015/06/05
[ "https://wordpress.stackexchange.com/questions/190625", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74171/" ]
How do I gee the numbered pagination of custom wpdb result? below code will show one latest post from each authors in the site. I want to show 20 posts per page with a numbered pagination. ``` $postids = $wpdb->get_results( " SELECT a.ID, a.post_title, a.post_author, a.post_date FROM $wpdb->posts a ...
You say "However, I know this is not a good way to do this" in your self answer. One thing I could add answering your question and using your answer is, you can use SQL\_CALC\_FOUND\_ROWS with $wpdb ``` $result = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM `wp_table` WHERE 1 LIMIT 10;" ); $total_count ...
190,629
<p>get_page_by_title works fine on plain text title. but when it comes to smart quotes and symbols like <code>#</code> it doesn't work. It fails to find post with the given title.</p> <p>For Example:-</p> <pre><code>get_page_by_title('The #1 Reason to Buy Right Now – THE MONEY!!', OBJECT, 'post'); </code></pre> <p>r...
[ { "answer_id": 190633, "author": "Frank P. Walentynowicz", "author_id": 32851, "author_profile": "https://wordpress.stackexchange.com/users/32851", "pm_score": 0, "selected": false, "text": "<p>The '#' character in title is not a problem. Second parameter of the function is a string. Cha...
2015/06/05
[ "https://wordpress.stackexchange.com/questions/190629", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/36718/" ]
get\_page\_by\_title works fine on plain text title. but when it comes to smart quotes and symbols like `#` it doesn't work. It fails to find post with the given title. For Example:- ``` get_page_by_title('The #1 Reason to Buy Right Now – THE MONEY!!', OBJECT, 'post'); ``` returns `NULL`. But there exists a post w...
You may need to html entity decode that title. Similar to the issue found [here](https://wordpress.stackexchange.com/questions/100445/get-page-by-title-not-working-when-used-with-a-variable/116541). Try this: ``` get_page_by_title( html_entity_decode('The #1 Reason to Buy Right Now – THE MONEY!!'), OBJECT, ...
190,646
<p>I have hierarchy like this: Category1 -Subcategory1 -Subcategory2 --Post1 Category2 -Subcategory1</p> <p>I need to show subcategories name and description when i go to category//// Now i use this code:</p> <pre><code> &lt;?php if (is_category()) { $this_category = get_category($cat); if (get_category_ch...
[ { "answer_id": 232819, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 1, "selected": false, "text": "<p>Your code checks for child categories and shows them if they exist, but you aren't then going on ...
2015/06/06
[ "https://wordpress.stackexchange.com/questions/190646", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74254/" ]
I have hierarchy like this: Category1 -Subcategory1 -Subcategory2 --Post1 Category2 -Subcategory1 I need to show subcategories name and description when i go to category//// Now i use this code: ``` <?php if (is_category()) { $this_category = get_category($cat); if (get_category_children($this_category->c...
Your code checks for child categories and shows them if they exist, but you aren't then going on to process the loop that would ordinarily display the posts in the current category. You want to extend your code to be of the form: ``` if ( is_category() ) { $this_category = get_category($cat); if ( get_categ...
190,670
<p>I am new to wordpress and this is the first html website I converted. After I converted my page to a wordpress theme, I notice that there is a white space on all sides of my page. This only happened after converting because my original html page doesn't have white spaces. I have *{padding:0; margin:0;} on my css but...
[ { "answer_id": 190682, "author": "Rahul S", "author_id": 74210, "author_profile": "https://wordpress.stackexchange.com/users/74210", "pm_score": -1, "selected": false, "text": "<p>Can you please give this in css file to avoid spaces</p>\n\n<p>html, body {\n margin: 0;\n pad...
2015/06/06
[ "https://wordpress.stackexchange.com/questions/190670", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74265/" ]
I am new to wordpress and this is the first html website I converted. After I converted my page to a wordpress theme, I notice that there is a white space on all sides of my page. This only happened after converting because my original html page doesn't have white spaces. I have \*{padding:0; margin:0;} on my css but i...
So I resolved it by adding body{padding: 0!important; margin: 0!important}. Didn't know that something was overriding my \*{padding: 0; margin: 0;}. Also, forgot to mention that the footer does not belong inside the wrapper which has a max-width of 1020px; because my psd file had the same width.
190,678
<p>I'm trying to change the look of my website but while doing that, facing some problems.</p> <p>Now, different classes and id's in style.css apply to all pages on my theme.</p> <p>I want to overwrite those styles elements (only 2 or 3) on my homepage.</p> <p>Now when I'm adding style in my index.php file, they are...
[ { "answer_id": 190682, "author": "Rahul S", "author_id": 74210, "author_profile": "https://wordpress.stackexchange.com/users/74210", "pm_score": -1, "selected": false, "text": "<p>Can you please give this in css file to avoid spaces</p>\n\n<p>html, body {\n margin: 0;\n pad...
2015/06/06
[ "https://wordpress.stackexchange.com/questions/190678", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/71530/" ]
I'm trying to change the look of my website but while doing that, facing some problems. Now, different classes and id's in style.css apply to all pages on my theme. I want to overwrite those styles elements (only 2 or 3) on my homepage. Now when I'm adding style in my index.php file, they are not being applied. I'v...
So I resolved it by adding body{padding: 0!important; margin: 0!important}. Didn't know that something was overriding my \*{padding: 0; margin: 0;}. Also, forgot to mention that the footer does not belong inside the wrapper which has a max-width of 1020px; because my psd file had the same width.
190,691
<p>i have this html mark-up to sort some data</p> <pre><code>&lt;div class="row"&gt; &lt;div class="col-xs-2"&gt; &lt;img src="images/member-schools/ms1.jpg" class="img-responsive"&gt; &lt;/div&gt; &lt;div class="col-xs-4"&gt; &lt;h4&gt;American International School - East&lt;/h4&gt; &lt;/div&gt; &lt;div class="co...
[ { "answer_id": 190686, "author": "Yadi", "author_id": 74279, "author_profile": "https://wordpress.stackexchange.com/users/74279", "pm_score": 1, "selected": false, "text": "<p>try \"update URL Plugin\" It updates all urls and content links in your website;\n<a href=\"http://www.velvetblu...
2015/06/06
[ "https://wordpress.stackexchange.com/questions/190691", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62794/" ]
i have this html mark-up to sort some data ``` <div class="row"> <div class="col-xs-2"> <img src="images/member-schools/ms1.jpg" class="img-responsive"> </div> <div class="col-xs-4"> <h4>American International School - East</h4> </div> <div class="col-xs-2"> <img src="images/member-schools/ms2.jpg" class="img-re...
**Method 1:** You can export your data from "Tools > Export" and for ensure export from database and rename old blog folder, then install WordPress in root & active WordPress Network. set url structure for new blog to sub-folder. now create new blog with "blog" name, login to blog & import old blog data. Your old post ...
190,701
<p>I have created a custom true/false field with the default value of true. I've set different posts to different values. However, get_field() always returns false:</p> <pre><code>&lt;?php if( have_posts() ): while( have_posts() ): the_post(); ?&gt; &lt;?php global var_dump(get_field('display_featured_imag...
[ { "answer_id": 190702, "author": "Hybrid Web Dev", "author_id": 36506, "author_profile": "https://wordpress.stackexchange.com/users/36506", "pm_score": 3, "selected": false, "text": "<p>You need to pass in the ID of the post you're trying to get the field from: Eg </p>\n\n<pre><code>get_...
2015/06/06
[ "https://wordpress.stackexchange.com/questions/190701", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74293/" ]
I have created a custom true/false field with the default value of true. I've set different posts to different values. However, get\_field() always returns false: ``` <?php if( have_posts() ): while( have_posts() ): the_post(); ?> <?php global var_dump(get_field('display_featured_image'));?> <?php endwhile...
You need to pass in the ID of the post you're trying to get the field from: Eg ``` get_field('display_featured_image', $post_id). ``` In a loop you could do ``` get_field('display_featured_image', get_the_id()); ``` ACF Stores field data in wp's meta\_fields, so you could even use WP's built in meta handler to...
190,757
<p>I'm moving a site from an Apache server to a nginx server. A lot of the pages have a .php extension at the end of the permalink. Trying to view those pages results in a nginx 404 Not Found. However those pages worked fine on Apache. Here is the server block config for the site:</p> <pre><code># Vhost Config: exampl...
[ { "answer_id": 190769, "author": "Dave Lozier", "author_id": 74314, "author_profile": "https://wordpress.stackexchange.com/users/74314", "pm_score": 0, "selected": false, "text": "<p>This sounds like a path info issue.</p>\n\n<p><a href=\"http://wiki.nginx.org/PHPFcgiExample\" rel=\"nofo...
2015/06/07
[ "https://wordpress.stackexchange.com/questions/190757", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74308/" ]
I'm moving a site from an Apache server to a nginx server. A lot of the pages have a .php extension at the end of the permalink. Trying to view those pages results in a nginx 404 Not Found. However those pages worked fine on Apache. Here is the server block config for the site: ``` # Vhost Config: example.com server ...
I ended up changing ``` location ~ ^/.*\.php$ { try_files $uri = 404; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } ``` to ``` location ~ ^/.*\.php$ { try_files $uri $uri/ /index.php?$args; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_i...
190,774
<p>I wanted to ask if ths is the best practice for calling an image into a parent theme file by using bloginfo('template_directory')?</p> <pre><code>&lt;img src="&lt;?php bloginfo('template_directory'); ?&gt;/img/logo.jpg" /&gt; </code></pre> <p>or should one use:</p> <pre><code>&lt;img src="&lt;?php echo get_templa...
[ { "answer_id": 190769, "author": "Dave Lozier", "author_id": 74314, "author_profile": "https://wordpress.stackexchange.com/users/74314", "pm_score": 0, "selected": false, "text": "<p>This sounds like a path info issue.</p>\n\n<p><a href=\"http://wiki.nginx.org/PHPFcgiExample\" rel=\"nofo...
2015/06/07
[ "https://wordpress.stackexchange.com/questions/190774", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/68130/" ]
I wanted to ask if ths is the best practice for calling an image into a parent theme file by using bloginfo('template\_directory')? ``` <img src="<?php bloginfo('template_directory'); ?>/img/logo.jpg" /> ``` or should one use: ``` <img src="<?php echo get_template_directory(); ?>/img/logo.jpg" /> ```
I ended up changing ``` location ~ ^/.*\.php$ { try_files $uri = 404; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } ``` to ``` location ~ ^/.*\.php$ { try_files $uri $uri/ /index.php?$args; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_i...
190,809
<p>I've looked at previous examples of this problem but I can't find a solution for what is causing this notice based on what I've seen from other people. This appears at the top of the screen when I am adding a new post.</p> <p>1145 is:</p> <pre><code>$post = get_post( $args[0] ); </code></pre> <p>I'm not getting a...
[ { "answer_id": 190812, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 4, "selected": true, "text": "<p>That error is because you are not providing the post ID to check capabilities:</p>\n\n<p>This line:</p>\n\n<pr...
2015/06/08
[ "https://wordpress.stackexchange.com/questions/190809", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73681/" ]
I've looked at previous examples of this problem but I can't find a solution for what is causing this notice based on what I've seen from other people. This appears at the top of the screen when I am adding a new post. 1145 is: ``` $post = get_post( $args[0] ); ``` I'm not getting any other kind of error so I'm not...
That error is because you are not providing the post ID to check capabilities: This line: ``` if( !current_user_can( 'edit_post' ) ) { ``` Should be: ``` if( !current_user_can( 'edit_post', $post_id ) ) { ```
190,817
<p>I've been having trouble Automatically Compiling my .scss files into my main WordPress style.css file.</p> <p>I'm using Leafo's SCSSPHP script and trying to achieve a few things.</p> <ol> <li><p>i'm using Kirki (<a href="http://kirki.org/" rel="nofollow">http://kirki.org/</a>) to override the WordPress Theme Custo...
[ { "answer_id": 190924, "author": "Aristeides", "author_id": 17078, "author_profile": "https://wordpress.stackexchange.com/users/17078", "pm_score": 0, "selected": false, "text": "<p>I'm currently experimenting with adding support for pre-processors in Kirki.\nYou can find instructions on...
2015/06/08
[ "https://wordpress.stackexchange.com/questions/190817", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54516/" ]
I've been having trouble Automatically Compiling my .scss files into my main WordPress style.css file. I'm using Leafo's SCSSPHP script and trying to achieve a few things. 1. i'm using Kirki (<http://kirki.org/>) to override the WordPress Theme Customizer and this is what i'm trying to do. Create my Panels/ Sections/...
I wanted to achieve the same thing.. What I ended up doing was creating a function that collects the Kirki variables (see [here](https://github.com/aristath/kirki/wiki/variables) about the use of variables in Kirki) and writes them to a scss.. ``` $file = get_template_directory() . '/sass/custom/_custom_vars_mixins_op...
190,823
<p>I want to display only a given level of menu items in my main nav menu when on that page. Currently sub menus of my main menu are part of the main menu HTML being an unordered list within the nav link list.</p> <pre><code>&lt;ul id="menu-main-top-navigation"&gt; &lt;li class="menu nav-1"&gt; ... ...
[ { "answer_id": 190875, "author": "Robbert", "author_id": 25834, "author_profile": "https://wordpress.stackexchange.com/users/25834", "pm_score": 0, "selected": false, "text": "<p>Maybe you can use <a href=\"https://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items\" rel=\"nofo...
2015/06/08
[ "https://wordpress.stackexchange.com/questions/190823", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51823/" ]
I want to display only a given level of menu items in my main nav menu when on that page. Currently sub menus of my main menu are part of the main menu HTML being an unordered list within the nav link list. ``` <ul id="menu-main-top-navigation"> <li class="menu nav-1"> ... <ul> <li clas...
You need to extend `Walker_Nav_Menu` in such a way that it only outputs, if I understand you, items that are not "zero" depth-- top level. ``` class my_extended_walker extends Walker_Nav_Menu { function start_lvl(&$output, $depth, $args ) { if (0 !== $depth) { parent::start_lvl($output, $depth, $args); ...
190,831
<p>How can I know what filter I can use to change anything and what my function have to return ?</p> <p>For exemple, sometimes I have to add a or a to a post title. It works (WP doesn't sanitize html tag here) but it's not readable when list the posts in admin because titles are always displayed as is, not HTML sani...
[ { "answer_id": 190875, "author": "Robbert", "author_id": 25834, "author_profile": "https://wordpress.stackexchange.com/users/25834", "pm_score": 0, "selected": false, "text": "<p>Maybe you can use <a href=\"https://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items\" rel=\"nofo...
2015/06/08
[ "https://wordpress.stackexchange.com/questions/190831", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70080/" ]
How can I know what filter I can use to change anything and what my function have to return ? For exemple, sometimes I have to add a or a to a post title. It works (WP doesn't sanitize html tag here) but it's not readable when list the posts in admin because titles are always displayed as is, not HTML sanitize. So, I...
You need to extend `Walker_Nav_Menu` in such a way that it only outputs, if I understand you, items that are not "zero" depth-- top level. ``` class my_extended_walker extends Walker_Nav_Menu { function start_lvl(&$output, $depth, $args ) { if (0 !== $depth) { parent::start_lvl($output, $depth, $args); ...
190,836
<p>I have array in post_meta like this:</p> <pre><code>array( 'option1' =&gt; 'true', 'option2' =&gt; 'true', 'option3' =&gt; 'false', option4' =&gt; 'true', 'option5' =&gt; 'false' ) </code></pre> <p>and I would like to filter <code>option1</code> with value true. Can someone help me?</p>
[ { "answer_id": 190875, "author": "Robbert", "author_id": 25834, "author_profile": "https://wordpress.stackexchange.com/users/25834", "pm_score": 0, "selected": false, "text": "<p>Maybe you can use <a href=\"https://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items\" rel=\"nofo...
2015/06/08
[ "https://wordpress.stackexchange.com/questions/190836", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74347/" ]
I have array in post\_meta like this: ``` array( 'option1' => 'true', 'option2' => 'true', 'option3' => 'false', option4' => 'true', 'option5' => 'false' ) ``` and I would like to filter `option1` with value true. Can someone help me?
You need to extend `Walker_Nav_Menu` in such a way that it only outputs, if I understand you, items that are not "zero" depth-- top level. ``` class my_extended_walker extends Walker_Nav_Menu { function start_lvl(&$output, $depth, $args ) { if (0 !== $depth) { parent::start_lvl($output, $depth, $args); ...
190,839
<p>When we add a class to a menu item through dashboard, the css class is added to "li" tag of that item. Is there a way to add these css classes to "a" tag of that item, instead of "li" tag?</p> <p><img src="https://i.stack.imgur.com/KNgtf.png" alt="enter image description here"></p> <p>As you can see in the picture...
[ { "answer_id": 190844, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 2, "selected": false, "text": "<p>Here are three approaches:</p>\n\n<h2>I - Plugin for the <code>a-class-</code> prefix:</h2>\n\n<p>We can tar...
2015/06/08
[ "https://wordpress.stackexchange.com/questions/190839", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74115/" ]
When we add a class to a menu item through dashboard, the css class is added to "li" tag of that item. Is there a way to add these css classes to "a" tag of that item, instead of "li" tag? ![enter image description here](https://i.stack.imgur.com/KNgtf.png) As you can see in the picture, I want to have this effect : ...
Here are three approaches: I - Plugin for the `a-class-` prefix: ------------------------------------- We can target the `<a>` tags with the `a-class-...` class prefix. So in your case the way to get: ``` <li id="menu-item-290" class="blue yellow ..."> <a class="red pink" href="http://localhost/en-wptuts/">home...
190,865
<p>I have following problem.</p> <p>When I try to search by tag or by category, I have 404 error. It means that when URL is like "domain.com/category/smt/" or "domain.com/tag/smt/", I have the error.</p> <p>I tried to edit category's link, but it didn't solve my problem. Changing template also doesn't solve this.</p>...
[ { "answer_id": 190844, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 2, "selected": false, "text": "<p>Here are three approaches:</p>\n\n<h2>I - Plugin for the <code>a-class-</code> prefix:</h2>\n\n<p>We can tar...
2015/06/08
[ "https://wordpress.stackexchange.com/questions/190865", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74367/" ]
I have following problem. When I try to search by tag or by category, I have 404 error. It means that when URL is like "domain.com/category/smt/" or "domain.com/tag/smt/", I have the error. I tried to edit category's link, but it didn't solve my problem. Changing template also doesn't solve this.
Here are three approaches: I - Plugin for the `a-class-` prefix: ------------------------------------- We can target the `<a>` tags with the `a-class-...` class prefix. So in your case the way to get: ``` <li id="menu-item-290" class="blue yellow ..."> <a class="red pink" href="http://localhost/en-wptuts/">home...
190,906
<p>How can i create unique slug while inserting a new post..</p> <p>I know i can query posts and compare the records to create unique slug but</p> <p>I want to insert a post with unique slug at the same time.</p> <p>Lets say i have post title and needed data for the post and want to insert it with wpquery Does wordp...
[ { "answer_id": 190908, "author": "Krzysiek Dróżdż", "author_id": 34172, "author_profile": "https://wordpress.stackexchange.com/users/34172", "pm_score": 2, "selected": false, "text": "<p>You don't have to think about it - WordPress will take care of this.</p>\n\n<p>Let's take a look at <...
2015/06/09
[ "https://wordpress.stackexchange.com/questions/190906", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62148/" ]
How can i create unique slug while inserting a new post.. I know i can query posts and compare the records to create unique slug but I want to insert a post with unique slug at the same time. Lets say i have post title and needed data for the post and want to insert it with wpquery Does wordpress have a function to ...
You don't have to think about it - WordPress will take care of this. Let's take a look at [`wp_insert_post` source code](https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-includes/post.php#L3094)... On line [3203](https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-includes/post.php#L3203) you'll find: ...
190,915
<p>I have this custom form inside a Wordpress page template</p> <pre><code>&lt;?php if(!is_user_logged_in()) { if(get_option('users_can_register')) { if($_POST){ $username = $wpdb-&gt;escape($_REQUEST['user_login']); if(empty($username)) { echo "&lt;span style='color:#FF0000'&gt;&lt;st...
[ { "answer_id": 190908, "author": "Krzysiek Dróżdż", "author_id": 34172, "author_profile": "https://wordpress.stackexchange.com/users/34172", "pm_score": 2, "selected": false, "text": "<p>You don't have to think about it - WordPress will take care of this.</p>\n\n<p>Let's take a look at <...
2015/06/09
[ "https://wordpress.stackexchange.com/questions/190915", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74398/" ]
I have this custom form inside a Wordpress page template ``` <?php if(!is_user_logged_in()) { if(get_option('users_can_register')) { if($_POST){ $username = $wpdb->escape($_REQUEST['user_login']); if(empty($username)) { echo "<span style='color:#FF0000'><strong>Error..</strong></span><...
You don't have to think about it - WordPress will take care of this. Let's take a look at [`wp_insert_post` source code](https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-includes/post.php#L3094)... On line [3203](https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-includes/post.php#L3203) you'll find: ...