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 |
|---|---|---|---|---|---|---|
156,654 | <p>I am building a reviewing system for user-submitted posts on my website. I have a page called <strong>page-review.php</strong> which displays the oldest post of the "pending review" category. This is to ensure that every user-submission gets reviewed. There is only one post displayed on this page at a time.</p>
<pr... | [
{
"answer_id": 156652,
"author": "adrian7",
"author_id": 7171,
"author_profile": "https://wordpress.stackexchange.com/users/7171",
"pm_score": 3,
"selected": true,
"text": "<p>That's because object properties are case sensitive, thus <code>$post->ID</code> is not the same as <code>$po... | 2014/08/03 | [
"https://wordpress.stackexchange.com/questions/156654",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22588/"
] | I am building a reviewing system for user-submitted posts on my website. I have a page called **page-review.php** which displays the oldest post of the "pending review" category. This is to ensure that every user-submission gets reviewed. There is only one post displayed on this page at a time.
```
$review_args = arra... | That's because object properties are case sensitive, thus `$post->ID` is not the same as `$post->id` .
Just by printing out these two you'll notice the difference, or do a print\_r of the `$post` object to see all of the available properties and methods. |
156,661 | <p>I tried this code, but it totally broke my site. I suppose it's because I'm doing something wrong in the WP_Query's sacred posts context in the sidebar template. Could some WP guru please correct this code? </p>
<pre><code><?php
$args = array(
'orderby' => 'date'
,'order' => 'DESC'
,'showpost... | [
{
"answer_id": 156652,
"author": "adrian7",
"author_id": 7171,
"author_profile": "https://wordpress.stackexchange.com/users/7171",
"pm_score": 3,
"selected": true,
"text": "<p>That's because object properties are case sensitive, thus <code>$post->ID</code> is not the same as <code>$po... | 2014/08/03 | [
"https://wordpress.stackexchange.com/questions/156661",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16142/"
] | I tried this code, but it totally broke my site. I suppose it's because I'm doing something wrong in the WP\_Query's sacred posts context in the sidebar template. Could some WP guru please correct this code?
```
<?php
$args = array(
'orderby' => 'date'
,'order' => 'DESC'
,'showposts'=>6
);
$my_query = ... | That's because object properties are case sensitive, thus `$post->ID` is not the same as `$post->id` .
Just by printing out these two you'll notice the difference, or do a print\_r of the `$post` object to see all of the available properties and methods. |
156,680 | <p>I looked up a bunch of threads trying to figure out how to automatically log a user in after registration, and came up with this.</p>
<pre><code>function automatically_log_me_in( $user_id ) {
$user = get_user_by('id',$user_id);
$username = $user->user_nicename;
$user_id = $user->ID;
wp_set_cur... | [
{
"answer_id": 157376,
"author": "phpsmashcode",
"author_id": 43844,
"author_profile": "https://wordpress.stackexchange.com/users/43844",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>I'm registering users with a custom registration form that directs to\n wp-login.php</p... | 2014/08/03 | [
"https://wordpress.stackexchange.com/questions/156680",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57585/"
] | I looked up a bunch of threads trying to figure out how to automatically log a user in after registration, and came up with this.
```
function automatically_log_me_in( $user_id ) {
$user = get_user_by('id',$user_id);
$username = $user->user_nicename;
$user_id = $user->ID;
wp_set_current_user($user_id, ... | **Short answer** - Your original function (mostly) works. This is your function edited to do what it needs to do:
```
function automatically_log_me_in( $user_id ) {
wp_set_current_user( $user_id );
wp_set_auth_cookie( $user_id );
wp_redirect( home_url( '/some-ending-page/' ) );
exit();
}
add_action( '... |
156,706 | <p>I can't get the correct css file to load for my page template. The page is correctly loading the template but still using the default css file.</p>
<p>This is the code I'm using to load the page template's css file: </p>
<pre><code>if (is_page_template('page-templates/page-nosidebar.php')) {
wp_enqu... | [
{
"answer_id": 156748,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 0,
"selected": false,
"text": "<p>There are a few problems with your code which I will take you through.</p>\n<p><strong>PROBLEM 1</stron... | 2014/08/04 | [
"https://wordpress.stackexchange.com/questions/156706",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57606/"
] | I can't get the correct css file to load for my page template. The page is correctly loading the template but still using the default css file.
This is the code I'm using to load the page template's css file:
```
if (is_page_template('page-templates/page-nosidebar.php')) {
wp_enqueue_style('authorLuncheon-la... | It seems the problem was it wasn't recognizing it was a page in the first place and thus couldn't recognize if there was a template applied to it.
Changed
```
if (is_page_template('page-templates/page-nosidebar.php')) {
```
to
```
if (is_page() && !is_page_template('page-templates/page-nosidebar.php')) {
``` |
156,723 | <p>The closest I've managed to get is:</p>
<pre><code>function redirect_to_local_110(){
wp_redirect("/", 302);
exit;
}
function add_home_link() {
add_menu_page( 'Course', 'Course', 'read', 'home', 'redirect_to_local_110', 'dashicons-welcome-learn-more');
}
add_action( 'admin_menu', 'add_home_link', 1001 );
<... | [
{
"answer_id": 156748,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 0,
"selected": false,
"text": "<p>There are a few problems with your code which I will take you through.</p>\n<p><strong>PROBLEM 1</stron... | 2014/08/04 | [
"https://wordpress.stackexchange.com/questions/156723",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57619/"
] | The closest I've managed to get is:
```
function redirect_to_local_110(){
wp_redirect("/", 302);
exit;
}
function add_home_link() {
add_menu_page( 'Course', 'Course', 'read', 'home', 'redirect_to_local_110', 'dashicons-welcome-learn-more');
}
add_action( 'admin_menu', 'add_home_link', 1001 );
```
However, ... | It seems the problem was it wasn't recognizing it was a page in the first place and thus couldn't recognize if there was a template applied to it.
Changed
```
if (is_page_template('page-templates/page-nosidebar.php')) {
```
to
```
if (is_page() && !is_page_template('page-templates/page-nosidebar.php')) {
``` |
156,742 | <p>I use the following line in a code which outputs subpages and a parent. This code outputs the name of the parent page. I would like to replace this with the word "Overview."</p>
<p>How do I achieve this in wp_list_pages with as little code as possible? Thanks!</p>
<pre><code>$children = wp_list_pages("title_li=yo&... | [
{
"answer_id": 156760,
"author": "Chinmoy Kumar Paul",
"author_id": 57436,
"author_profile": "https://wordpress.stackexchange.com/users/57436",
"pm_score": 0,
"selected": false,
"text": "<p>Try this code snippets once:</p>\n\n<pre><code>$args = array('post_type' => 'page', 'parent' =&... | 2014/08/04 | [
"https://wordpress.stackexchange.com/questions/156742",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5205/"
] | I use the following line in a code which outputs subpages and a parent. This code outputs the name of the parent page. I would like to replace this with the word "Overview."
How do I achieve this in wp\_list\_pages with as little code as possible? Thanks!
```
$children = wp_list_pages("title_li=yo&include=".$post->po... | You could of course use some `preg_replace()` tricks to solve this, but here's a little (untested) idea using the `the_title` filter instead:
```
add_filter( 'the_title', 'wpse_title' );
$children = wp_list_pages("title_li=&include=".$post->post_parent."&echo=0");
```
where our filter callback is:
```
function... |
156,753 | <p>Is it possible to add custom css to a stylesheet in a theme depending on whether the user is logged in or not? </p>
<p>When I log in, the theme navigation and when viewing the main site bar is hidden behind the wpadminbar and I would like to change the css of the theme nav bar only when an admin is logged in and wh... | [
{
"answer_id": 156760,
"author": "Chinmoy Kumar Paul",
"author_id": 57436,
"author_profile": "https://wordpress.stackexchange.com/users/57436",
"pm_score": 0,
"selected": false,
"text": "<p>Try this code snippets once:</p>\n\n<pre><code>$args = array('post_type' => 'page', 'parent' =&... | 2014/08/04 | [
"https://wordpress.stackexchange.com/questions/156753",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23507/"
] | Is it possible to add custom css to a stylesheet in a theme depending on whether the user is logged in or not?
When I log in, the theme navigation and when viewing the main site bar is hidden behind the wpadminbar and I would like to change the css of the theme nav bar only when an admin is logged in and when the sit... | You could of course use some `preg_replace()` tricks to solve this, but here's a little (untested) idea using the `the_title` filter instead:
```
add_filter( 'the_title', 'wpse_title' );
$children = wp_list_pages("title_li=&include=".$post->post_parent."&echo=0");
```
where our filter callback is:
```
function... |
156,774 | <p>I am trying to redirect users based on the following...</p>
<ul>
<li>If Role = Customer & Page Is NOT ID 6 Then Redirect To Checkout</li>
<li>If Not Logged in & Page Is Not ID 6 then redirect to login</li>
<li><p>User role = member and Page ID is 6 redirect to home page</p>
<p>
<pre><code>//If Role = Cust... | [
{
"answer_id": 156775,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 1,
"selected": false,
"text": "<p><strong>EDIT</strong></p>\n\n<p>You are using <a href=\"http://codex.wordpress.org/Function_Reference/a... | 2014/08/04 | [
"https://wordpress.stackexchange.com/questions/156774",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10247/"
] | I am trying to redirect users based on the following...
* If Role = Customer & Page Is NOT ID 6 Then Redirect To Checkout
* If Not Logged in & Page Is Not ID 6 then redirect to login
* User role = member and Page ID is 6 redirect to home page
```
//If Role = Customer & Page Is ID 6 Then Redirect To Checkout
if ( user... | **EDIT**
You are using [`auth_redirect();`](http://codex.wordpress.org/Function_Reference/auth_redirect), by default it checks if a user is logged in or not, so you don't need to check again if a user is logged in or not
>
> When this code is called from a page, it checks to see if the user viewing the page is logge... |
156,789 | <p>I would like to include some text at the end of every post. Like how some people write "Like my posts? Follow me on twitter!" or something like that. There are some buttons for users to tweet or share the posts, but I want to see how people would respond to explicit suggestions.</p>
<p>I thought maybe I can just co... | [
{
"answer_id": 156790,
"author": "jdm2112",
"author_id": 45202,
"author_profile": "https://wordpress.stackexchange.com/users/45202",
"pm_score": 1,
"selected": false,
"text": "<p>What is referred to as a \"template part\" seems to fit exactly your need here.</p>\n\n<p><a href=\"http://co... | 2014/08/04 | [
"https://wordpress.stackexchange.com/questions/156789",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47805/"
] | I would like to include some text at the end of every post. Like how some people write "Like my posts? Follow me on twitter!" or something like that. There are some buttons for users to tweet or share the posts, but I want to see how people would respond to explicit suggestions.
I thought maybe I can just copy-paste i... | You can try the [`the_content`](http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content) filter, to *append*/*prepend* text to the post content.
Here's a simple example:
```
add_filter( 'the_content', function( $content ) {
if( is_single() && has_tag( 'follow-me-on-twitter' ) )
{
$content ... |
156,853 | <p>I used <code>is_sidebar_active('NameOfSidebar')</code>, but it seems not working. It returns false all the time. I wanna have a condition that goes like this</p>
<pre><code>if('sidebar is not active'){
//must not display the section title.
}else{
//display the sidebar here..
}
</code></pre>
| [
{
"answer_id": 156862,
"author": "Brad Dalton",
"author_id": 9884,
"author_profile": "https://wordpress.stackexchange.com/users/9884",
"pm_score": 2,
"selected": false,
"text": "<p>Try <a href=\"http://codex.wordpress.org/Function_Reference/is_active_sidebar\" rel=\"nofollow\"><code>is_a... | 2014/08/05 | [
"https://wordpress.stackexchange.com/questions/156853",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57681/"
] | I used `is_sidebar_active('NameOfSidebar')`, but it seems not working. It returns false all the time. I wanna have a condition that goes like this
```
if('sidebar is not active'){
//must not display the section title.
}else{
//display the sidebar here..
}
``` | Try [`is_active_sidebar`](http://codex.wordpress.org/Function_Reference/is_active_sidebar)
```
if ( is_active_sidebar('your-sidebar-i.d'))
```
Where your-sidebar-i.d equals the I.D you use when you register the sidebar. |
156,861 | <p>I have used this code;</p>
<pre><code>$roleObject = get_role( 'editor' );
if (!$roleObject->has_cap( 'edit_theme_options' ) ) {
$roleObject->add_cap( 'edit_theme_options' );
}
</code></pre>
<p>to add menu access for editors.</p>
<p>I have a custom post type 'Masterclasses". That appears correctly in the... | [
{
"answer_id": 156864,
"author": "echoashu",
"author_id": 54871,
"author_profile": "https://wordpress.stackexchange.com/users/54871",
"pm_score": 0,
"selected": false,
"text": "<p>You can try giving capabilities for something like <code>add_cap( 'edit_Masterclasses' )</code></p>\n\n<p>Fo... | 2014/08/05 | [
"https://wordpress.stackexchange.com/questions/156861",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57686/"
] | I have used this code;
```
$roleObject = get_role( 'editor' );
if (!$roleObject->has_cap( 'edit_theme_options' ) ) {
$roleObject->add_cap( 'edit_theme_options' );
}
```
to add menu access for editors.
I have a custom post type 'Masterclasses". That appears correctly in the Administrator's Menu editing page but ... | As ever, when you know the answer it's maddeningly simple. The custom post types were there all along, together with their taxonomy. All posts are absent from the menu editor and have to be turned on in Screen Options.
I pressed the button and lo, there they were. |
156,866 | <p>i want to create my own slideshow without using any slider plugins
hear is my code</p>
<p>-- in the footer ---</p>
<pre><code><script type="text/javascript" src="<?php bloginfo( 'template_url' );?>/js/jquery.cycle.all.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.... | [
{
"answer_id": 156864,
"author": "echoashu",
"author_id": 54871,
"author_profile": "https://wordpress.stackexchange.com/users/54871",
"pm_score": 0,
"selected": false,
"text": "<p>You can try giving capabilities for something like <code>add_cap( 'edit_Masterclasses' )</code></p>\n\n<p>Fo... | 2014/08/05 | [
"https://wordpress.stackexchange.com/questions/156866",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51993/"
] | i want to create my own slideshow without using any slider plugins
hear is my code
-- in the footer ---
```
<script type="text/javascript" src="<?php bloginfo( 'template_url' );?>/js/jquery.cycle.all.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></... | As ever, when you know the answer it's maddeningly simple. The custom post types were there all along, together with their taxonomy. All posts are absent from the menu editor and have to be turned on in Screen Options.
I pressed the button and lo, there they were. |
156,869 | <p>This page</p>
<p><a href="https://wordpress.org/support/article/hardening-wordpress/" rel="nofollow noreferrer">https://wordpress.org/support/article/hardening-wordpress/</a></p>
<p>says this should be included in the .htaccess file to block requests for files inside the includes dir.</p>
<pre><code># Block the incl... | [
{
"answer_id": 156893,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": true,
"text": "<p>You ask:</p>\n\n<blockquote>\n <p>How does that work ? As far as I can read it, it only specifies not to\n r... | 2014/08/05 | [
"https://wordpress.stackexchange.com/questions/156869",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25973/"
] | This page
<https://wordpress.org/support/article/hardening-wordpress/>
says this should be included in the .htaccess file to block requests for files inside the includes dir.
```
# Block the include-only files.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^wp-admin/includes/ - [F,L]
RewriteRul... | You ask:
>
> How does that work ? As far as I can read it, it only specifies not to
> rewrite certain urls (using -),
>
>
>
These files are *included* within the WordPress PHP scripts, so there's no need to access them in the browser, **but** notice the rewrite *flags*.
Here's some information on the `F`, `L` a... |
156,907 | <p>We migrated our site to a new host and changed the domain name, and now all pages are displaying errors:</p>
<blockquote>
<p>Warning: include_once(includes/class-wc-download-handler.php) [function.include-once]: failed to open stream: No such file or directory in /home/content/34/11939834/html/wp-content/plugins/... | [
{
"answer_id": 156946,
"author": "Advanced SEO",
"author_id": 25053,
"author_profile": "https://wordpress.stackexchange.com/users/25053",
"pm_score": 0,
"selected": false,
"text": "<p>This is common issue when migrating from one host to another. You have those errors because path to incl... | 2014/08/05 | [
"https://wordpress.stackexchange.com/questions/156907",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57707/"
] | We migrated our site to a new host and changed the domain name, and now all pages are displaying errors:
>
> Warning: include\_once(includes/class-wc-download-handler.php) [function.include-once]: failed to open stream: No such file or directory in /home/content/34/11939834/html/wp-content/plugins/woocommerce/woocomm... | I discovered some useful resources about GoDaddy hosting and its malware screening:
The files in question were *uploaded* to the GoDaddy server, but they were *deleted* by GoDaddy without a Failed Upload notification. Here is what comes up in FileZilla
```
Command: STOR class-wc-download-handler.php
Response: 15... |
156,909 | <p>I'm working on a theme and one of the features I'm quite happy with is the slider supports background videos. The problem is however, that Wordpress (although I think it's more a PHP issue) has a limit of 2MB on file uploads, and as you know, most videos are bigger than that.</p>
<p>So I haven't got that much exper... | [
{
"answer_id": 156946,
"author": "Advanced SEO",
"author_id": 25053,
"author_profile": "https://wordpress.stackexchange.com/users/25053",
"pm_score": 0,
"selected": false,
"text": "<p>This is common issue when migrating from one host to another. You have those errors because path to incl... | 2014/08/05 | [
"https://wordpress.stackexchange.com/questions/156909",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52645/"
] | I'm working on a theme and one of the features I'm quite happy with is the slider supports background videos. The problem is however, that Wordpress (although I think it's more a PHP issue) has a limit of 2MB on file uploads, and as you know, most videos are bigger than that.
So I haven't got that much experience with... | I discovered some useful resources about GoDaddy hosting and its malware screening:
The files in question were *uploaded* to the GoDaddy server, but they were *deleted* by GoDaddy without a Failed Upload notification. Here is what comes up in FileZilla
```
Command: STOR class-wc-download-handler.php
Response: 15... |
156,967 | <p>I know that this question is asked numerous but i din't find an answer that suits to me. </p>
<p>Well i'm made some custom post types and some custom taxonomies. I have the custom post type <strong>Products</strong> and linked to it the taxonomy <strong>Product Categories</strong>. When the user is at the <em>Produ... | [
{
"answer_id": 156971,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>What you are describing is loosely related to \"faceted search\", but you aren't quite searching. :)</p>\n\n<p>In a... | 2014/08/06 | [
"https://wordpress.stackexchange.com/questions/156967",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34844/"
] | I know that this question is asked numerous but i din't find an answer that suits to me.
Well i'm made some custom post types and some custom taxonomies. I have the custom post type **Products** and linked to it the taxonomy **Product Categories**. When the user is at the *Products* page and clicks on a *Product Cate... | The way I read you question is that you need 12 posts per page in this taxonomy regardless of the current term been displayed.
This can be easily done with [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts). You should never change the main query for a custom query on archive pages... |
156,978 | <p>I have a custom post type called <code>slide</code>. It has content and some custom fields. I want <strong>WP</strong> to show the <code>single.php</code> theme or <code>single-slide.php</code> theme when the user clicks the slide single page link. the problem I have is that <strong>WP</strong> throws 404 error, whe... | [
{
"answer_id": 156983,
"author": "Chinmoy Kumar Paul",
"author_id": 57436,
"author_profile": "https://wordpress.stackexchange.com/users/57436",
"pm_score": 5,
"selected": false,
"text": "<p>Flush the rewrite rule from dashboard -> Settings->Permalink page. Click on save button and then c... | 2014/08/06 | [
"https://wordpress.stackexchange.com/questions/156978",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50960/"
] | I have a custom post type called `slide`. It has content and some custom fields. I want **WP** to show the `single.php` theme or `single-slide.php` theme when the user clicks the slide single page link. the problem I have is that **WP** throws 404 error, when I want to see the single slide page.
here is my code in `fu... | You should set your `publicly_queryable` argument to `true` when registering your custom post type.
**TAKE NOTE**: Add [`flush_rewrite_rules()`](http://codex.wordpress.org/Function_Reference/flush_rewrite_rules), refresh the page once or twice and REMOVE IT IMMEDIATELY. You SHOULD NOT keep `flush_rewrite_rules()` unle... |
157,005 | <p>I have a WordPress site where I am adding a custom style to the main navigation based on whether the user is on that page. The articles section of my site has several articles within it that users can visit. </p>
<p>I use this css style as seen below which has the desired effect when the viewer is on the articles p... | [
{
"answer_id": 156983,
"author": "Chinmoy Kumar Paul",
"author_id": 57436,
"author_profile": "https://wordpress.stackexchange.com/users/57436",
"pm_score": 5,
"selected": false,
"text": "<p>Flush the rewrite rule from dashboard -> Settings->Permalink page. Click on save button and then c... | 2014/08/06 | [
"https://wordpress.stackexchange.com/questions/157005",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23507/"
] | I have a WordPress site where I am adding a custom style to the main navigation based on whether the user is on that page. The articles section of my site has several articles within it that users can visit.
I use this css style as seen below which has the desired effect when the viewer is on the articles page, WordP... | You should set your `publicly_queryable` argument to `true` when registering your custom post type.
**TAKE NOTE**: Add [`flush_rewrite_rules()`](http://codex.wordpress.org/Function_Reference/flush_rewrite_rules), refresh the page once or twice and REMOVE IT IMMEDIATELY. You SHOULD NOT keep `flush_rewrite_rules()` unle... |
157,014 | <p>I was having an issue where my menu was being created using:</p>
<pre><code>wp_nav_menu(array('theme_location' => 'main_menu', 'menu_class' => 'sf-menu''))
</code></pre>
<p>The resulting HTML was like this:</p>
<pre><code><div class='sf-menu'><ul><li...></ul></div>
</code></pre... | [
{
"answer_id": 157015,
"author": "DavGarcia",
"author_id": 48539,
"author_profile": "https://wordpress.stackexchange.com/users/48539",
"pm_score": 1,
"selected": true,
"text": "<p>The reason this was happening was simple - I had just installed the theme and had not yet associated a menu ... | 2014/08/06 | [
"https://wordpress.stackexchange.com/questions/157014",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48539/"
] | I was having an issue where my menu was being created using:
```
wp_nav_menu(array('theme_location' => 'main_menu', 'menu_class' => 'sf-menu''))
```
The resulting HTML was like this:
```
<div class='sf-menu'><ul><li...></ul></div>
```
As you can see, the `$menu_class` argument was being applied to the div instead... | The reason this was happening was simple - I had just installed the theme and had not yet associated a menu with the 'main\_menu' theme location. Once I had the menu assigned, the markup generated acted as expected.
To assign a menu, go to Appearance > Menus then select the Manage Locations tab. On there you can choos... |
157,044 | <p>I'm trying to add Pinterest's nopin="nopin" HTML attribute to the comment avatar image tags on my blog. Here's the function I'm using to call the avatar on each comment:</p>
<pre><code>get_avatar($comment, 50, vol_random_image())
</code></pre>
<p>vol_random_image() just selects an image from an array if the commen... | [
{
"answer_id": 157050,
"author": "Chinmoy Kumar Paul",
"author_id": 57436,
"author_profile": "https://wordpress.stackexchange.com/users/57436",
"pm_score": 0,
"selected": false,
"text": "<p>Actually there have no filter option for Avatar HTML markup. But I think that you can do it by odd... | 2014/08/07 | [
"https://wordpress.stackexchange.com/questions/157044",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8719/"
] | I'm trying to add Pinterest's nopin="nopin" HTML attribute to the comment avatar image tags on my blog. Here's the function I'm using to call the avatar on each comment:
```
get_avatar($comment, 50, vol_random_image())
```
vol\_random\_image() just selects an image from an array if the commenter doesn't have a Grava... | You can use the [`get_avatar`](http://codex.wordpress.org/Plugin_API/Filter_Reference/get_avatar) filter to modify the output of the image tag and add your HTML attribute
```
return apply_filters( 'get_avatar', $avatar, $id_or_email, $size, $default, $alt );
$avatar : Image tag for the user's avatar.
``` |
157,046 | <p>From those who are more experienced with WP, I could use some advice on how to best set up a local history site to do the following:</p>
<ul>
<li><p>There will be a list of <em>articles</em> on different historical topics. Each will be tagged with the <em>people</em> who appear in the article, the <em>organizations... | [
{
"answer_id": 157050,
"author": "Chinmoy Kumar Paul",
"author_id": 57436,
"author_profile": "https://wordpress.stackexchange.com/users/57436",
"pm_score": 0,
"selected": false,
"text": "<p>Actually there have no filter option for Avatar HTML markup. But I think that you can do it by odd... | 2014/08/07 | [
"https://wordpress.stackexchange.com/questions/157046",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57786/"
] | From those who are more experienced with WP, I could use some advice on how to best set up a local history site to do the following:
* There will be a list of *articles* on different historical topics. Each will be tagged with the *people* who appear in the article, the *organizations* discussed, and maybe other metad... | You can use the [`get_avatar`](http://codex.wordpress.org/Plugin_API/Filter_Reference/get_avatar) filter to modify the output of the image tag and add your HTML attribute
```
return apply_filters( 'get_avatar', $avatar, $id_or_email, $size, $default, $alt );
$avatar : Image tag for the user's avatar.
``` |
157,056 | <p>Using the automatic update of my self-hosted WordPress blogs, I configured automatic updates of both the WordPress core as well as WordPress plugins and themes (<a href="http://wordpress.org/plugins/wp-updates-settings/">through this plugin</a>).</p>
<p>Whenever a core update occurs, I get an email like:</p>
<bloc... | [
{
"answer_id": 157057,
"author": "Abhik",
"author_id": 26991,
"author_profile": "https://wordpress.stackexchange.com/users/26991",
"pm_score": 4,
"selected": true,
"text": "<p>In your <code>functions.php</code> add: </p>\n\n<pre><code>add_filter( 'auto_core_update_send_email', '__return... | 2014/08/07 | [
"https://wordpress.stackexchange.com/questions/157056",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2128/"
] | Using the automatic update of my self-hosted WordPress blogs, I configured automatic updates of both the WordPress core as well as WordPress plugins and themes ([through this plugin](http://wordpress.org/plugins/wp-updates-settings/)).
Whenever a core update occurs, I get an email like:
>
> *Your site has updated to... | In your `functions.php` add:
```
add_filter( 'auto_core_update_send_email', '__return_false' );
``` |
157,086 | <p>I looked at WP's site and didn't see a role I could use. I can create my own, but how do I limit the content on the page itself? Some private and some public information can be on the same page. I could create two pages, but I didn't know if WP had a way to do this or where I might build my security to allow this... | [
{
"answer_id": 157087,
"author": "gdaniel",
"author_id": 30984,
"author_profile": "https://wordpress.stackexchange.com/users/30984",
"pm_score": 0,
"selected": false,
"text": "<p>Although this was mean to block the whole page, it can be used to block just parts of a page.</p>\n\n<pre><co... | 2014/08/07 | [
"https://wordpress.stackexchange.com/questions/157086",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49089/"
] | I looked at WP's site and didn't see a role I could use. I can create my own, but how do I limit the content on the page itself? Some private and some public information can be on the same page. I could create two pages, but I didn't know if WP had a way to do this or where I might build my security to allow this.
How... | If you're wanting to limit by a capability (built in or custom) you can use [current\_user\_can()](http://codex.wordpress.org/Function_Reference/current_user_can) and pass the appropriate [capability](http://codex.wordpress.org/Roles_and_Capabilities).
```
if( current_user_can('manage_options') ) {
echo "Hi there... |
157,100 | <p>I'm looking to get a plain list of the unique categories in a custom loop (only categories for the posts in the loop). I've been fumbling with some code for a bit and here's what I've got:</p>
<pre><code><?php
$args = array(
'post_status'=>'publish',
'post_type'=>'post',
'posts_... | [
{
"answer_id": 157103,
"author": "Chinmoy Kumar Paul",
"author_id": 57436,
"author_profile": "https://wordpress.stackexchange.com/users/57436",
"pm_score": 0,
"selected": false,
"text": "<p><strong>EDIT</strong></p>\n\n<p>You are saving the categories in the array. This is very good. I a... | 2014/08/07 | [
"https://wordpress.stackexchange.com/questions/157100",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11747/"
] | I'm looking to get a plain list of the unique categories in a custom loop (only categories for the posts in the loop). I've been fumbling with some code for a bit and here's what I've got:
```
<?php
$args = array(
'post_status'=>'publish',
'post_type'=>'post',
'posts_per_page'=>-1
);
... | EDIT: Moved `$i = 0` outside the loop. That should get you the full list of categories.
```
$get_posts = new WP_Query();
$i = 0;
$get_posts->query($args);
if($get_posts->have_posts()) {
$cats = array();
while($get_posts->have_posts()) { $get_posts->the_post();
$post_categories = wp_get_post_categories(... |
157,170 | <p>I am using the Multipostthumbnails plugin - <a href="https://wordpress.org/plugins/multiple-post-thumbnails/" rel="nofollow">https://wordpress.org/plugins/multiple-post-thumbnails/</a></p>
<p>And it has a certain naming convention to it. I know the usual way to output a placeholder if no featured image set, but not... | [
{
"answer_id": 157171,
"author": "kraftner",
"author_id": 47733,
"author_profile": "https://wordpress.stackexchange.com/users/47733",
"pm_score": 1,
"selected": false,
"text": "<p>Next time having a look at the docs might help ;)</p>\n\n<pre><code>MultiPostThumbnails::has_post_thumbnail(... | 2014/08/08 | [
"https://wordpress.stackexchange.com/questions/157170",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57698/"
] | I am using the Multipostthumbnails plugin - <https://wordpress.org/plugins/multiple-post-thumbnails/>
And it has a certain naming convention to it. I know the usual way to output a placeholder if no featured image set, but not with their code?
I obviously want something like -
```
if ( has_post_thumbnail($post->ID) ... | I think that you're adding the code inside the loop of index.php or blog template file. You might be try this kind of things:
```
if ( class_exists( 'MultiPostThumbnails' ) &&
( MultiPostThumbnails::has_post_thumbnail( get_post_type(), 'header-image' , get_the_ID() ) ) ) {
MultiPostThumbnails::the_post_t... |
157,191 | <p>Whenever you add a image gallery to a post, the images automatically link to the image attachment pages. This is not ideal, because I want to use <a href="http://fancyapps.com/fancybox/" rel="nofollow">Fancybox</a> so the user can cycle through the images.</p>
<p>I tried the following code to let the images link to... | [
{
"answer_id": 157194,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 4,
"selected": true,
"text": "<p>You can override the gallery shortcode <code>link</code> attribute with:</p>\n\n<pre><code>add_filter( 'shortc... | 2014/08/08 | [
"https://wordpress.stackexchange.com/questions/157191",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8015/"
] | Whenever you add a image gallery to a post, the images automatically link to the image attachment pages. This is not ideal, because I want to use [Fancybox](http://fancyapps.com/fancybox/) so the user can cycle through the images.
I tried the following code to let the images link to the files by default, but this does... | You can override the gallery shortcode `link` attribute with:
```
add_filter( 'shortcode_atts_gallery',
function( $out ){
$out['link'] = 'file';
return $out;
}
);
```
This means that even if your shortcodes are:
```
[gallery ids="1,2,3"]
[gallery ids="1,2,3" link="none"]
```
the gallery o... |
157,201 | <p>I would like to ask whether there is a function to remove/turn off the Text tab for users ?</p>
<p>Enough good codes here to make a clean CMS, only this one I can not find.</p>
<p><img src="https://i.stack.imgur.com/8E8R5.jpg" alt="Screenshot"></p>
| [
{
"answer_id": 157227,
"author": "Philip Newcomer",
"author_id": 57889,
"author_profile": "https://wordpress.stackexchange.com/users/57889",
"pm_score": 2,
"selected": true,
"text": "<p>This requires two steps:</p>\n\n<p>1) First, we need to hide the editor tabs, which can be accomplishe... | 2014/08/08 | [
"https://wordpress.stackexchange.com/questions/157201",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57885/"
] | I would like to ask whether there is a function to remove/turn off the Text tab for users ?
Enough good codes here to make a clean CMS, only this one I can not find.
 | This requires two steps:
1) First, we need to hide the editor tabs, which can be accomplished easily enough using CSS. We'll output some CSS to the admin head to do that:
```php
function hide_editor_tabs() {
global $pagenow;
// Only output the CSS if we're on the edit post or add new post screens.
if ( !... |
157,206 | <p>I am trying to pass username to database through form:</p>
<pre><code>[insert_php]
$current_user= wp_get_current_user();
$id= $current_user->user_login;
[/insert_php]
<input type="hidden" name="id" value="[insert_php]$id[/insert_php]">
</code></pre>
<p>But it doesn't get through, the rest of visible in... | [
{
"answer_id": 157219,
"author": "CTala",
"author_id": 54524,
"author_profile": "https://wordpress.stackexchange.com/users/54524",
"pm_score": -1,
"selected": false,
"text": "<p>What you want is to use :</p>\n\n<pre><code>$id = get_current_user_id()\n</code></pre>\n\n<p>What the function... | 2014/08/08 | [
"https://wordpress.stackexchange.com/questions/157206",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14948/"
] | I am trying to pass username to database through form:
```
[insert_php]
$current_user= wp_get_current_user();
$id= $current_user->user_login;
[/insert_php]
<input type="hidden" name="id" value="[insert_php]$id[/insert_php]">
```
But it doesn't get through, the rest of visible inputs do go through though. | If you want to output the `$id`, you need to echo.
*Also be sure to use [`esc_attr()`](https://developer.wordpress.org/reference/functions/esc_attr/) as a good security practice.*
```
<input type="hidden" name="id" value="[insert_php]echo esc_attr( $id );[/insert_php]">
```
---
In addition, as was noted in anoth... |
157,208 | <p>In single.php I tried to add inside the loop the <code>previous_post_link</code> and <code>next_post_link</code>. But nothing is rendered when a view the source of the site. I added the <code>previous_post_link</code> inside an <code>h4</code> tag to see it better. Normally I'll add it in <code>pagination-bottom</co... | [
{
"answer_id": 157210,
"author": "Philip Newcomer",
"author_id": 57889,
"author_profile": "https://wordpress.stackexchange.com/users/57889",
"pm_score": 0,
"selected": false,
"text": "<p>The third parameter in your <code>previous_post_link()</code> function call is set to <code>true</cod... | 2014/08/08 | [
"https://wordpress.stackexchange.com/questions/157208",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34844/"
] | In single.php I tried to add inside the loop the `previous_post_link` and `next_post_link`. But nothing is rendered when a view the source of the site. I added the `previous_post_link` inside an `h4` tag to see it better. Normally I'll add it in `pagination-bottom`. Why is this happening?
Here is my code
```
<?ph... | **EDIT**
Referring back to one of your [previous questions](https://wordpress.stackexchange.com/q/156967/31545) I've answered, you are using custom taxonomies, so this is most likely your problem then. You then have to set the `taxonomy` parameter accordingly. See my original answer
**ORIGINAL ANSWER**
There are a f... |
157,212 | <p>In our site, we've got some old code sitting in the header. I'm guessing it originated from a plugin we used to use (embedding Scribd content into the site), but we are no longer using it. </p>
<pre><code><script type="text/javascript" src="http://www.scribd.com/javascripts/view.js"></script>
</code></p... | [
{
"answer_id": 157214,
"author": "Howard E",
"author_id": 57589,
"author_profile": "https://wordpress.stackexchange.com/users/57589",
"pm_score": 2,
"selected": true,
"text": "<p>If you have SSH, go to your <code>wp-content</code> directory and grep it.</p>\n\n<pre><code>/ grep -HRn 'scr... | 2014/08/08 | [
"https://wordpress.stackexchange.com/questions/157212",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54061/"
] | In our site, we've got some old code sitting in the header. I'm guessing it originated from a plugin we used to use (embedding Scribd content into the site), but we are no longer using it.
```
<script type="text/javascript" src="http://www.scribd.com/javascripts/view.js"></script>
```
The problem is I can't figure ... | If you have SSH, go to your `wp-content` directory and grep it.
```
/ grep -HRn 'scribd' .
``` |
157,230 | <p>I have an <a href="https://ifttt.com/wordpress" rel="nofollow">IFTTT recipe</a> that creates posts for me on some occasion, but for some weird reason it creates three, sometimes four posts of the same content.</p>
<p>I would like to add an <code>add_action</code> hook/callback to validate what will be a new post an... | [
{
"answer_id": 157261,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 4,
"selected": true,
"text": "<p>It looks like the <code>xmlrpc_prepare_post</code> filter is only applied to the output of the <code>wp_getPos... | 2014/08/09 | [
"https://wordpress.stackexchange.com/questions/157230",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26551/"
] | I have an [IFTTT recipe](https://ifttt.com/wordpress) that creates posts for me on some occasion, but for some weird reason it creates three, sometimes four posts of the same content.
I would like to add an `add_action` hook/callback to validate what will be a new post and, if it already exists, cancel the post, or mo... | It looks like the `xmlrpc_prepare_post` filter is only applied to the output of the `wp_getPost` and `wp_getRevision` methods of the `wp_xmlrpc_server` class.
It would be great if this code line:
```
do_action( 'xmlrpc_call', 'wp.newPost' );
```
would be replaced with extra input arguments, for example:
```
do_act... |
157,253 | <p>I need to update all posts on my wordpress site on a scheduled time (every day). So I wanted to create a new page template which I can call everyday through a cronjob to update all the posts at once.</p>
<p>I have already created the page and the cronjob, but the code I add inside doesn't seem to be working. Can yo... | [
{
"answer_id": 157255,
"author": "Dan Bough",
"author_id": 45074,
"author_profile": "https://wordpress.stackexchange.com/users/45074",
"pm_score": 0,
"selected": false,
"text": "<p>You aren't actually doing anything to the post. You need to create an array with updated info and pass tha... | 2014/08/09 | [
"https://wordpress.stackexchange.com/questions/157253",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57908/"
] | I need to update all posts on my wordpress site on a scheduled time (every day). So I wanted to create a new page template which I can call everyday through a cronjob to update all the posts at once.
I have already created the page and the cronjob, but the code I add inside doesn't seem to be working. Can you please l... | This is what I used, if I'm understanding you correctly.
```
UPDATE wp_posts SET post_date=NOW(),post_date_gmt=NOW(),post_modified=NOW(),post_modified_gmt=NOW();
```
Worked for me. |
157,263 | <p>I want to use conditional tag to display content according to month. Such as if it is April, it should show something else something else. Right now I am using :</p>
<pre><code><?php if(is_month() == '2' ) : ?>
<p>hello</p>
<?php else: ?>
<p>Wow</p>
<?php endif ?>... | [
{
"answer_id": 157255,
"author": "Dan Bough",
"author_id": 45074,
"author_profile": "https://wordpress.stackexchange.com/users/45074",
"pm_score": 0,
"selected": false,
"text": "<p>You aren't actually doing anything to the post. You need to create an array with updated info and pass tha... | 2014/08/09 | [
"https://wordpress.stackexchange.com/questions/157263",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54940/"
] | I want to use conditional tag to display content according to month. Such as if it is April, it should show something else something else. Right now I am using :
```
<?php if(is_month() == '2' ) : ?>
<p>hello</p>
<?php else: ?>
<p>Wow</p>
<?php endif ?>
```
The above doesn't work. Any solution? | This is what I used, if I'm understanding you correctly.
```
UPDATE wp_posts SET post_date=NOW(),post_date_gmt=NOW(),post_modified=NOW(),post_modified_gmt=NOW();
```
Worked for me. |
157,295 | <p>I'm fixing a wordpress plugin that uses a 1.0.0 version of jquery. The jquery version automatically included in wordpress is 1.11.0. In a test site, the plugin is dependent on the 1.0.0 jquery and doesn't work on the latest version.</p>
<p>However, it works on a test site because the plugin is loaded BEFORE the wp-... | [
{
"answer_id": 157296,
"author": "bonger",
"author_id": 57034,
"author_profile": "https://wordpress.stackexchange.com/users/57034",
"pm_score": 3,
"selected": true,
"text": "<p>1.0.0? Really?! Anyway you could try the <code>print_scripts_array</code> filter:</p>\n\n<pre><code>// Hack of ... | 2014/08/10 | [
"https://wordpress.stackexchange.com/questions/157295",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57933/"
] | I'm fixing a wordpress plugin that uses a 1.0.0 version of jquery. The jquery version automatically included in wordpress is 1.11.0. In a test site, the plugin is dependent on the 1.0.0 jquery and doesn't work on the latest version.
However, it works on a test site because the plugin is loaded BEFORE the wp-includes/j... | 1.0.0? Really?! Anyway you could try the `print_scripts_array` filter:
```
// Hack of wp_prototype_before_jquery() in "wp-includes/script-loader.php"
function wpse157295_print_scripts_array( $js_array ) {
if ( false === $jquery = array_search( 'jquery-core', $js_array, true ) ) // Now 'jquery-core', not 'jquery'
... |
157,313 | <p>This incredible website and the genius developers here have helped me significantly in the course of my WP Dev over the years, firstly THANK YOU.</p>
<p>I am now faced with a problem that I have been trying to find a solution to for the past 3 days and is driving me insane, but might be easy for one of you genius's... | [
{
"answer_id": 157296,
"author": "bonger",
"author_id": 57034,
"author_profile": "https://wordpress.stackexchange.com/users/57034",
"pm_score": 3,
"selected": true,
"text": "<p>1.0.0? Really?! Anyway you could try the <code>print_scripts_array</code> filter:</p>\n\n<pre><code>// Hack of ... | 2014/08/10 | [
"https://wordpress.stackexchange.com/questions/157313",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57937/"
] | This incredible website and the genius developers here have helped me significantly in the course of my WP Dev over the years, firstly THANK YOU.
I am now faced with a problem that I have been trying to find a solution to for the past 3 days and is driving me insane, but might be easy for one of you genius's!
The pro... | 1.0.0? Really?! Anyway you could try the `print_scripts_array` filter:
```
// Hack of wp_prototype_before_jquery() in "wp-includes/script-loader.php"
function wpse157295_print_scripts_array( $js_array ) {
if ( false === $jquery = array_search( 'jquery-core', $js_array, true ) ) // Now 'jquery-core', not 'jquery'
... |
157,328 | <p>I managed to set up a query carousel slider on my test-site. How can i adapt the slider to show the 5 latest posts from my featured post category with thumb, title and link to the post instead of the manuel written html parts?</p>
<p><a href="http://jsfiddle.net/u9cL59qh/" rel="nofollow"><strong>Here is the fiddle<... | [
{
"answer_id": 157367,
"author": "HML",
"author_id": 57681,
"author_profile": "https://wordpress.stackexchange.com/users/57681",
"pm_score": -1,
"selected": false,
"text": "<p>Maybe you can change your query something like this:</p>\n\n<pre><code>('showposts=5&orderby=post_date&o... | 2014/08/10 | [
"https://wordpress.stackexchange.com/questions/157328",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45407/"
] | I managed to set up a query carousel slider on my test-site. How can i adapt the slider to show the 5 latest posts from my featured post category with thumb, title and link to the post instead of the manuel written html parts?
[**Here is the fiddle**](http://jsfiddle.net/u9cL59qh/)
I already find a code to show up th... | Firstly I have edited your code to remove the thumbnail between the ul and the li as you cannot place anything there and placed it in a p tag for demonstration purposes only you can change it to whatever you like. I have also added a next and previous button for you after the ul and a div to contain the slider...
```
... |
157,340 | <p>I created simple custom post type with few taxonomies. I </p>
<pre><code><?php $query_params = getQueryParams(); $query_params['post_type'] = 'client';
if(isset($query_params['search'])){
$query_params['post_title_like'] = $query_params['search'];
unset($query_params['search']);
}
$l... | [
{
"answer_id": 157367,
"author": "HML",
"author_id": 57681,
"author_profile": "https://wordpress.stackexchange.com/users/57681",
"pm_score": -1,
"selected": false,
"text": "<p>Maybe you can change your query something like this:</p>\n\n<pre><code>('showposts=5&orderby=post_date&o... | 2014/08/10 | [
"https://wordpress.stackexchange.com/questions/157340",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40659/"
] | I created simple custom post type with few taxonomies. I
```
<?php $query_params = getQueryParams(); $query_params['post_type'] = 'client';
if(isset($query_params['search'])){
$query_params['post_title_like'] = $query_params['search'];
unset($query_params['search']);
}
$loop = new WP_Quer... | Firstly I have edited your code to remove the thumbnail between the ul and the li as you cannot place anything there and placed it in a p tag for demonstration purposes only you can change it to whatever you like. I have also added a next and previous button for you after the ul and a div to contain the slider...
```
... |
157,343 | <p>Is it possible to override this <code>widget</code> function from a parent theme? I saw this blog, but it dealt with a simpler case.</p>
<p><a href="http://venutip.com/content/right-way-override-theme-functions" rel="nofollow noreferrer">http://venutip.com/content/right-way-override-theme-functions</a></p>
<h3>paren... | [
{
"answer_id": 157350,
"author": "a378853",
"author_id": 57952,
"author_profile": "https://wordpress.stackexchange.com/users/57952",
"pm_score": 4,
"selected": true,
"text": "<p>You simply need to run your code on a higher priority than what the parent theme is, the default on <code>add_... | 2014/08/10 | [
"https://wordpress.stackexchange.com/questions/157343",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57947/"
] | Is it possible to override this `widget` function from a parent theme? I saw this blog, but it dealt with a simpler case.
<http://venutip.com/content/right-way-override-theme-functions>
### parent
```
class Chocolat_Widget_New_Entrys extends WP_Widget {
function __construct() {...
function widget( $args, $inst... | You simply need to run your code on a higher priority than what the parent theme is, the default on `add_action` function is 10 so you can use:
```
function s157343_unregister_widgets() {
unregister_widget( 'Chocolat_Widget_New_Entrys' );
}
add_action( 'widgets_init', 's157343_unregister_widgets', 20 );
```
Thi... |
157,360 | <p>I have a custom template and I inserted the following snippet to get rid of the admin bar for the page:</p>
<pre><code>function hide_admin_bar(){ return false; }
add_filter( 'show_admin_bar', 'hide_admin_bar' );
</code></pre>
<p>The problem is this still leaves a blank white empty bar at the top of the page with a... | [
{
"answer_id": 157361,
"author": "Adam",
"author_id": 37125,
"author_profile": "https://wordpress.stackexchange.com/users/37125",
"pm_score": 0,
"selected": false,
"text": "<p>It is kind of hackish but I found adding the below snippet inline just like WordPress core did the trick. I hate... | 2014/08/11 | [
"https://wordpress.stackexchange.com/questions/157360",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37125/"
] | I have a custom template and I inserted the following snippet to get rid of the admin bar for the page:
```
function hide_admin_bar(){ return false; }
add_filter( 'show_admin_bar', 'hide_admin_bar' );
```
The problem is this still leaves a blank white empty bar at the top of the page with a height of 32px. Looking a... | You can set the display status with [show\_admin\_bar function](http://codex.wordpress.org/Function_Reference/show_admin_bar)
```
<?php show_admin_bar( false ); ?>
``` |
157,390 | <p>I want to build statistics-like tables with the count of posts in given custom taxonomy terms and display them by year along with the total post count from that year.</p>
<p>For example:</p>
<blockquote>
<p><strong>2014</strong></p>
<p>|_Taxonomy Term A: 8 posts</p>
<p>|_ Taxonomy Term B: 12 posts</p>
... | [
{
"answer_id": 157468,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 4,
"selected": true,
"text": "<p><strong>EDIT 2</strong></p>\n\n<p>Here is another version of the code in <em>EDIT 1</em>. This code is a... | 2014/08/11 | [
"https://wordpress.stackexchange.com/questions/157390",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52621/"
] | I want to build statistics-like tables with the count of posts in given custom taxonomy terms and display them by year along with the total post count from that year.
For example:
>
> **2014**
>
>
> |\_Taxonomy Term A: 8 posts
>
>
> |\_ Taxonomy Term B: 12 posts
>
>
> **Total posts in 2014:** 20 posts
>
>
> ... | **EDIT 2**
Here is another version of the code in *EDIT 1*. This code is about much more faster. Here is my test between the code in *EDIT 1* and *EDIT 2*
* *EDIT 1* Database query time = +/- 0.25 and Database queries = 69
* *EDIT 2* Database query time = +/- 0.07 and Database queries = 29
Here is the code
```
<?ph... |
157,396 | <p>So, I have a foreach loop within get_pages that shows a list of child pages within a parent ID.</p>
<p>The titles, featured image, and links come through fine, however I can't get excerpts to show up at all. I'm referencing <a href="http://codex.wordpress.org/Function_Reference/get_pages" rel="nofollow">http://code... | [
{
"answer_id": 157408,
"author": "Romain",
"author_id": 56396,
"author_profile": "https://wordpress.stackexchange.com/users/56396",
"pm_score": -1,
"selected": false,
"text": "<p>Has you are requesting the excerpt of every post inside your query, you need to setup your post data for each... | 2014/08/11 | [
"https://wordpress.stackexchange.com/questions/157396",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47505/"
] | So, I have a foreach loop within get\_pages that shows a list of child pages within a parent ID.
The titles, featured image, and links come through fine, however I can't get excerpts to show up at all. I'm referencing <http://codex.wordpress.org/Function_Reference/get_pages>
```
$args = array(
'child_of' => 1... | You can use [this function `wp_trim_words()`](http://codex.wordpress.org/Function_Reference/wp_trim_words). It allows you to format the output, and strips all the HTML tags in the content (it uses `wp_strip_all_tags`).
You will have to pass `post_content` as the first paramenter. |
157,467 | <p>Firstly, I am a newbie when it comes to php. I have a plugin that periodically imports posts into my website. Normally, it should check if the post already exists, and if it does, it updates it. Otherwise it creates a new one. Now for some reason, it always takes the <code>else</code> path no matter what. </p>
<p>T... | [
{
"answer_id": 157475,
"author": "the",
"author_id": 44793,
"author_profile": "https://wordpress.stackexchange.com/users/44793",
"pm_score": 1,
"selected": false,
"text": "<p>I suspect that PHP considers the value of <code>$wpdb->get_row(\"SELECT * FROM wp_posts WHERE post_title = '\"... | 2014/08/11 | [
"https://wordpress.stackexchange.com/questions/157467",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58008/"
] | Firstly, I am a newbie when it comes to php. I have a plugin that periodically imports posts into my website. Normally, it should check if the post already exists, and if it does, it updates it. Otherwise it creates a new one. Now for some reason, it always takes the `else` path no matter what.
The `if` is like this:... | I suspect that PHP considers the value of `$wpdb->get_row("SELECT * FROM wp_posts WHERE post_title = '" . $title . "'", 'ARRAY_A');` to be true no matter what (see also [this](https://stackoverflow.com/questions/2382490/how-does-true-false-work-in-php)). You'll have to count the number of rows that are returned
Try so... |
157,478 | <p>I am struggling with front/landing page customization for my custom designed theme. I have designed custom theme and pretty much coded it using the <em>Underscore boilerplate</em>. </p>
<p>As I understands, the codex suggests that I create a front-page.php and customize it there. In <em>setting>reading</em> I selec... | [
{
"answer_id": 157481,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>You can use:</p>\n\n<p><code>get_the_post_thumbnail($recent['ID'], 'post-thumbnail');</code></p>\n\n<p>in order t... | 2014/08/11 | [
"https://wordpress.stackexchange.com/questions/157478",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57934/"
] | I am struggling with front/landing page customization for my custom designed theme. I have designed custom theme and pretty much coded it using the *Underscore boilerplate*.
As I understands, the codex suggests that I create a front-page.php and customize it there. In *setting>reading* I selected A static/Front page ... | I would tend not to go with [`wp_get_recent_posts`](http://codex.wordpress.org/Function_Reference/wp_get_recent_posts) or even [`get_posts`](http://codex.wordpress.org/Function_Reference/get_posts) for custom queries like this. By default, template tags like `the_excerpt()` is not available to these functions, and you ... |
157,479 | <p>I'm building a plug-in which is going great so far. I want to start making it localization ready. I don't know what is going wrong, but it's bugging out on me when I try to load it in Poedit.</p>
<p>So let's do this step by step as multiple tutorials show me to.</p>
<p>So in myplugin.php I load the following to te... | [
{
"answer_id": 157481,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>You can use:</p>\n\n<p><code>get_the_post_thumbnail($recent['ID'], 'post-thumbnail');</code></p>\n\n<p>in order t... | 2014/08/11 | [
"https://wordpress.stackexchange.com/questions/157479",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58001/"
] | I'm building a plug-in which is going great so far. I want to start making it localization ready. I don't know what is going wrong, but it's bugging out on me when I try to load it in Poedit.
So let's do this step by step as multiple tutorials show me to.
So in myplugin.php I load the following to tell WP where my la... | I would tend not to go with [`wp_get_recent_posts`](http://codex.wordpress.org/Function_Reference/wp_get_recent_posts) or even [`get_posts`](http://codex.wordpress.org/Function_Reference/get_posts) for custom queries like this. By default, template tags like `the_excerpt()` is not available to these functions, and you ... |
157,480 | <p>With the advancement of internet browsers, I find myself more and more comfortable using SVGS when coding websites... especially for icons, and simple graphics that can be replaced on the fly by pngs.</p>
<p>It looks like wordpress almost supports SVGS. I say almost because:</p>
<ol>
<li><p>It's not by default an ... | [
{
"answer_id": 165826,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>Just from reading the source (not testing), I can see that the extension needs to match:</p>\n\n<pre><code>if ( 'i... | 2014/08/11 | [
"https://wordpress.stackexchange.com/questions/157480",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30984/"
] | With the advancement of internet browsers, I find myself more and more comfortable using SVGS when coding websites... especially for icons, and simple graphics that can be replaced on the fly by pngs.
It looks like wordpress almost supports SVGS. I say almost because:
1. It's not by default an allowed file type in wo... | Take a look at `wp_prepare_attachment_for_js()`, which is what gathers attachment metadata for use on the Media pages. The eponymous filter lets us add or alter metadata.
The following example can be dropped into functions.php. Note: this requires SimpleXML support in PHP.
```
function common_svg_media_thumbnails($re... |
157,496 | <p>I am trying to create a shortcode for 2 of my theme option. Basically I want to grabe my theme options to my shortcode so that I can display them anywhere on my posts something like this:</p>
<pre><code>[ads_1] [ads_2]
</code></pre>
<p>However when I tried to get the options on my shortcode it wont work at all and... | [
{
"answer_id": 165826,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>Just from reading the source (not testing), I can see that the extension needs to match:</p>\n\n<pre><code>if ( 'i... | 2014/08/12 | [
"https://wordpress.stackexchange.com/questions/157496",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58023/"
] | I am trying to create a shortcode for 2 of my theme option. Basically I want to grabe my theme options to my shortcode so that I can display them anywhere on my posts something like this:
```
[ads_1] [ads_2]
```
However when I tried to get the options on my shortcode it wont work at all and its giving me an error
... | Take a look at `wp_prepare_attachment_for_js()`, which is what gathers attachment metadata for use on the Media pages. The eponymous filter lets us add or alter metadata.
The following example can be dropped into functions.php. Note: this requires SimpleXML support in PHP.
```
function common_svg_media_thumbnails($re... |
157,527 | <p>I have written a security function.I want to call this function in all pages which are created by wordpress back end only (Does not want want to called by all php files).Is there any hook available?.Please Help</p>
| [
{
"answer_id": 165826,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>Just from reading the source (not testing), I can see that the extension needs to match:</p>\n\n<pre><code>if ( 'i... | 2014/08/12 | [
"https://wordpress.stackexchange.com/questions/157527",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63966/"
] | I have written a security function.I want to call this function in all pages which are created by wordpress back end only (Does not want want to called by all php files).Is there any hook available?.Please Help | Take a look at `wp_prepare_attachment_for_js()`, which is what gathers attachment metadata for use on the Media pages. The eponymous filter lets us add or alter metadata.
The following example can be dropped into functions.php. Note: this requires SimpleXML support in PHP.
```
function common_svg_media_thumbnails($re... |
157,536 | <p>I recently added a network to my multi-network wordpress install (that is, a single install with multiple subdomain networks, each with multiple subdirectory sites). </p>
<p>Although everything appears normal on the new site from the front end and network admin view, any users I add to the site automatically get re... | [
{
"answer_id": 165826,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>Just from reading the source (not testing), I can see that the extension needs to match:</p>\n\n<pre><code>if ( 'i... | 2014/08/12 | [
"https://wordpress.stackexchange.com/questions/157536",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32053/"
] | I recently added a network to my multi-network wordpress install (that is, a single install with multiple subdomain networks, each with multiple subdirectory sites).
Although everything appears normal on the new site from the front end and network admin view, any users I add to the site automatically get redirected t... | Take a look at `wp_prepare_attachment_for_js()`, which is what gathers attachment metadata for use on the Media pages. The eponymous filter lets us add or alter metadata.
The following example can be dropped into functions.php. Note: this requires SimpleXML support in PHP.
```
function common_svg_media_thumbnails($re... |
157,561 | <p>I have some doubt about the <a href="http://codex.wordpress.org/Function_Reference/wp_get_archives" rel="nofollow"><code>wp_get_archives()</code> function</a></p>
<p>In my website I have create the following page template that use the <code>wp_get_archives()</code> function to show the posts list:</p>
<pre><code>&... | [
{
"answer_id": 165826,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>Just from reading the source (not testing), I can see that the extension needs to match:</p>\n\n<pre><code>if ( 'i... | 2014/08/12 | [
"https://wordpress.stackexchange.com/questions/157561",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29275/"
] | I have some doubt about the [`wp_get_archives()` function](http://codex.wordpress.org/Function_Reference/wp_get_archives)
In my website I have create the following page template that use the `wp_get_archives()` function to show the posts list:
```
<?php
/**
* Template Name: Posts Archive
*
* A cu... | Take a look at `wp_prepare_attachment_for_js()`, which is what gathers attachment metadata for use on the Media pages. The eponymous filter lets us add or alter metadata.
The following example can be dropped into functions.php. Note: this requires SimpleXML support in PHP.
```
function common_svg_media_thumbnails($re... |
157,562 | <p>I'm using the new(ish) filter <code>add_action( 'user_new_form', 'funcy', 9 );</code> to add custom fields to Create A New User page. I'm then using </p>
<pre><code>add_action( 'personal_options_update', 'save_user_meta' );
add_action( 'edit_user_profile_update', 'save_user_meta' );
</code></pre>
<p>hooks to save ... | [
{
"answer_id": 157567,
"author": "Shazzad",
"author_id": 42967,
"author_profile": "https://wordpress.stackexchange.com/users/42967",
"pm_score": 2,
"selected": true,
"text": "<p>For this, you have to use <code>user_register</code> hook defined on <em>wp-includes/users.php line 1759</em>.... | 2014/08/12 | [
"https://wordpress.stackexchange.com/questions/157562",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7355/"
] | I'm using the new(ish) filter `add_action( 'user_new_form', 'funcy', 9 );` to add custom fields to Create A New User page. I'm then using
```
add_action( 'personal_options_update', 'save_user_meta' );
add_action( 'edit_user_profile_update', 'save_user_meta' );
```
hooks to save my meta on other edit user pages. I'v... | For this, you have to use `user_register` hook defined on *wp-includes/users.php line 1759*.
* `personal_options_update` hook is called, when an user updating his
own profile.
* `edit_user_profile_update` is called, when an administrator updating other user profile.
* nothing is called, when an administrator creating ... |
157,563 | <p>I've trying to search high and low for this but am having a really hard time.</p>
<p>Essentially, I have a custom post type called <code>locations</code> with taxonomies. The posts in "locations" are categorized under several taxonomies called <code>markets</code>, <code>products</code>, <code>size</code>, <code>co... | [
{
"answer_id": 157565,
"author": "Tomás Cot",
"author_id": 57843,
"author_profile": "https://wordpress.stackexchange.com/users/57843",
"pm_score": 1,
"selected": false,
"text": "<p>I think this is what you are looking for <a href=\"http://codex.wordpress.org/Function_Reference/the_terms\... | 2014/08/12 | [
"https://wordpress.stackexchange.com/questions/157563",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58060/"
] | I've trying to search high and low for this but am having a really hard time.
Essentially, I have a custom post type called `locations` with taxonomies. The posts in "locations" are categorized under several taxonomies called `markets`, `products`, `size`, `country`, etc."
I just need to know how I can get it so my c... | As there's multiple Taxonomies, you will need to loop through all of the assigned taxonomies of that post type. `get_object_taxonomies` is the function which returns array of post type taxonomies.
```
global $post;
foreach ( get_object_taxonomies( $post ) as $tax_name ){
$taxonomy = get_taxonomy( $tax_name );
... |
157,577 | <p>From my understanding of how WordPress updates core and plugins is that every 12 hours it goes out and looks for updates. When does that time get set? 12 hours from initial installation? I ask this because using the plugin auto-update filter <a href="http://codex.wordpress.org/Configuring_Automatic_Background_Update... | [
{
"answer_id": 157582,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 3,
"selected": false,
"text": "<p>The relevant functions <a href=\"http://queryposts.com/function/wp_update_plugins/\"><code>wp_update_plugins()</cod... | 2014/08/12 | [
"https://wordpress.stackexchange.com/questions/157577",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7355/"
] | From my understanding of how WordPress updates core and plugins is that every 12 hours it goes out and looks for updates. When does that time get set? 12 hours from initial installation? I ask this because using the plugin auto-update filter [`add_filter( 'auto_update_plugin' );`](http://codex.wordpress.org/Configuring... | You are correct, Wordpress checks for updates to core and plugins every 12 hours, but a better way to word it would be: it checks updates if last update was more than 12 hours ago.
The 12 hour setting is hard codded in `wp-includes/update.php`
The last updated dates are stored in `wp_options` table and the options a... |
157,579 | <p>I have some doubts about how work the WordPress <strong>the_date()</strong> functions definied into <strong>general-template.php</strong></p>
<p>In a page I show the posts archive using this code snippet into a loop:</p>
<pre><code><article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> ... | [
{
"answer_id": 157580,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p>As it says right there is its inline documentation — the function is meant to only output the result \"once per dat... | 2014/08/12 | [
"https://wordpress.stackexchange.com/questions/157579",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29275/"
] | I have some doubts about how work the WordPress **the\_date()** functions definied into **general-template.php**
In a page I show the posts archive using this code snippet into a loop:
```
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header>
<h3 class="ent... | For historical bloggy reasons, `the_date` in WordPress won't show the same date twice in a row. This is for grouping purposes.
The fix is easy: Use `the_time` instead. It behaves exactly the same as `the_date`, but without the internal historical logic. Also no need to rewrite any complicated code, just change three c... |
157,640 | <p>Imagine a CPT, let us call it "News". This News Post type is mainly used for displaying short News inline on the front page. But some of those News will be longer, mandating to only display an excerpt on the front page and having a single view. The rule would probably be that I put the text used on the front page in... | [
{
"answer_id": 157673,
"author": "Welcher",
"author_id": 27210,
"author_profile": "https://wordpress.stackexchange.com/users/27210",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>Just filtering those without content probably wouldn't suffice</p>\n</blockquote>\n\n<p>Why n... | 2014/08/13 | [
"https://wordpress.stackexchange.com/questions/157640",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47733/"
] | Imagine a CPT, let us call it "News". This News Post type is mainly used for displaying short News inline on the front page. But some of those News will be longer, mandating to only display an excerpt on the front page and having a single view. The rule would probably be that I put the text used on the front page in th... | My idea is simple: **register the CPT using `'publicly_queryable' => TRUE`** and then conditionally makes the post type not publicly queryable when a single news that has no content is queried.
This implies that we have to change `'publicly_queryable'` argument after the post type is registered. Something easy: all po... |
157,643 | <p>I'm trying to retrieve some values stored in the option panel of WordPress, however the list of the <a href="http://codex.wordpress.org/Option_Reference" rel="nofollow">options I found</a> on the site seems not complete.
Perhaps it's me looking in the wrong place.</p>
<p>What for getting the name of the author of a... | [
{
"answer_id": 157673,
"author": "Welcher",
"author_id": 27210,
"author_profile": "https://wordpress.stackexchange.com/users/27210",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>Just filtering those without content probably wouldn't suffice</p>\n</blockquote>\n\n<p>Why n... | 2014/08/13 | [
"https://wordpress.stackexchange.com/questions/157643",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26216/"
] | I'm trying to retrieve some values stored in the option panel of WordPress, however the list of the [options I found](http://codex.wordpress.org/Option_Reference) on the site seems not complete.
Perhaps it's me looking in the wrong place.
What for getting the name of the author of a given post? | My idea is simple: **register the CPT using `'publicly_queryable' => TRUE`** and then conditionally makes the post type not publicly queryable when a single news that has no content is queried.
This implies that we have to change `'publicly_queryable'` argument after the post type is registered. Something easy: all po... |
157,661 | <p>I've got my discussion settings set to allow people to comment without registering, so the comment form has the standard Name, Email, Website and Comment, and this is working exactly as I want.</p>
<p>The only problem is that if someone uses an admin's screenname and email, it looks as though the comment has come f... | [
{
"answer_id": 157673,
"author": "Welcher",
"author_id": 27210,
"author_profile": "https://wordpress.stackexchange.com/users/27210",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>Just filtering those without content probably wouldn't suffice</p>\n</blockquote>\n\n<p>Why n... | 2014/08/13 | [
"https://wordpress.stackexchange.com/questions/157661",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58105/"
] | I've got my discussion settings set to allow people to comment without registering, so the comment form has the standard Name, Email, Website and Comment, and this is working exactly as I want.
The only problem is that if someone uses an admin's screenname and email, it looks as though the comment has come from the ad... | My idea is simple: **register the CPT using `'publicly_queryable' => TRUE`** and then conditionally makes the post type not publicly queryable when a single news that has no content is queried.
This implies that we have to change `'publicly_queryable'` argument after the post type is registered. Something easy: all po... |
157,664 | <p>I have a login top bar I use for general users on the website front end and the admin like to use the wordpress admin bar. I am trying to find a way of hiding the login top bar for admin so they just use the wordpress admin bar (this is only enabled for admin). I would also like to change the CSS of the main contain... | [
{
"answer_id": 157673,
"author": "Welcher",
"author_id": 27210,
"author_profile": "https://wordpress.stackexchange.com/users/27210",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>Just filtering those without content probably wouldn't suffice</p>\n</blockquote>\n\n<p>Why n... | 2014/08/13 | [
"https://wordpress.stackexchange.com/questions/157664",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17412/"
] | I have a login top bar I use for general users on the website front end and the admin like to use the wordpress admin bar. I am trying to find a way of hiding the login top bar for admin so they just use the wordpress admin bar (this is only enabled for admin). I would also like to change the CSS of the main container ... | My idea is simple: **register the CPT using `'publicly_queryable' => TRUE`** and then conditionally makes the post type not publicly queryable when a single news that has no content is queried.
This implies that we have to change `'publicly_queryable'` argument after the post type is registered. Something easy: all po... |
157,700 | <p>I am very new in PHP and WordPress development and I have the following problem trying to insert some HTML code into the posts loop.</p>
<p>I tried something like it:</p>
<pre><code><?php
if (have_posts()) :
<ul>
// Start the Loop.
while (have_posts()) : the_post();
/*
* Incl... | [
{
"answer_id": 157703,
"author": "Abhik",
"author_id": 26991,
"author_profile": "https://wordpress.stackexchange.com/users/26991",
"pm_score": 2,
"selected": false,
"text": "<p>You are including HTML elements without closing the php tags. Also, the last one should be <code>endif</code>, ... | 2014/08/13 | [
"https://wordpress.stackexchange.com/questions/157700",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29275/"
] | I am very new in PHP and WordPress development and I have the following problem trying to insert some HTML code into the posts loop.
I tried something like it:
```
<?php
if (have_posts()) :
<ul>
// Start the Loop.
while (have_posts()) : the_post();
/*
* Include the post format-specific t... | You're not adding HTML code to your file, you're adding invalid PHP.
To recap, in PHP everything between `<?php` and `?>` is PHP code.
So this is valid PHP:
```
<?php echo 'hello world';! ?>
```
This is also valid:
```
<b><?php echo 'hello world'; ?></b>
```
This is not valid:
```
<?php <b> echo 'hello world';... |
157,705 | <p>My host sent me the following message:</p>
<blockquote>
<p>Below are the recently upload scripts that contain code to send email.
You may wish to inspect them to ensure they are not sending out SPAM.</p>
<p>/home/swthief/public_html/wp-login.php:392: if ( $message &&
!wp_mail( $user_email, wp... | [
{
"answer_id": 157703,
"author": "Abhik",
"author_id": 26991,
"author_profile": "https://wordpress.stackexchange.com/users/26991",
"pm_score": 2,
"selected": false,
"text": "<p>You are including HTML elements without closing the php tags. Also, the last one should be <code>endif</code>, ... | 2014/08/13 | [
"https://wordpress.stackexchange.com/questions/157705",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57465/"
] | My host sent me the following message:
>
> Below are the recently upload scripts that contain code to send email.
> You may wish to inspect them to ensure they are not sending out SPAM.
>
>
> /home/swthief/public\_html/wp-login.php:392: if ( $message &&
> !wp\_mail( $user\_email, wp\_specialchars\_decode( $title ... | You're not adding HTML code to your file, you're adding invalid PHP.
To recap, in PHP everything between `<?php` and `?>` is PHP code.
So this is valid PHP:
```
<?php echo 'hello world';! ?>
```
This is also valid:
```
<b><?php echo 'hello world'; ?></b>
```
This is not valid:
```
<?php <b> echo 'hello world';... |
157,727 | <p>I have set my front page set to be a static front page, "Home," and my Posts page is set to my "News" page.</p>
<p>When on my News page, <code>is_home()</code> returns <code>1</code> as expected but <code>is_archive()</code> returns <code>0</code>. I would expect that it would return <code>1</code> also. The WP doc... | [
{
"answer_id": 157730,
"author": "Amirmasoud",
"author_id": 58133,
"author_profile": "https://wordpress.stackexchange.com/users/58133",
"pm_score": 2,
"selected": false,
"text": "<p>if you have home.php/index.php on your theme it's your first page and function is_home() return true in th... | 2014/08/13 | [
"https://wordpress.stackexchange.com/questions/157727",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27667/"
] | I have set my front page set to be a static front page, "Home," and my Posts page is set to my "News" page.
When on my News page, `is_home()` returns `1` as expected but `is_archive()` returns `0`. I would expect that it would return `1` also. The WP doc for `is_archive()` doesn't make it clearer for me. It reads,
> ... | To properly understand the difference, you have to dig into the Wordpress Core
* [`is_archive()`](http://codex.wordpress.org/Function_Reference/is_archive) (defined in [wp-includes/query.php#L140](https://core.trac.wordpress.org/browser/tags/3.9.2/src/wp-includes/query.php#L140)) checks any type of archive page. These... |
157,728 | <p>I'm trying to get posts from 2 or more categories, so far I discovered:</p>
<pre><code>$args = array(
'category__in'=>array( implode(ot_get_option("beautiful_categories"), ",") )
);
$query = new WP_Query( $args );
</code></pre>
<p>I'm using OptionTree and that will return categories ids with "," between t... | [
{
"answer_id": 157730,
"author": "Amirmasoud",
"author_id": 58133,
"author_profile": "https://wordpress.stackexchange.com/users/58133",
"pm_score": 2,
"selected": false,
"text": "<p>if you have home.php/index.php on your theme it's your first page and function is_home() return true in th... | 2014/08/13 | [
"https://wordpress.stackexchange.com/questions/157728",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58133/"
] | I'm trying to get posts from 2 or more categories, so far I discovered:
```
$args = array(
'category__in'=>array( implode(ot_get_option("beautiful_categories"), ",") )
);
$query = new WP_Query( $args );
```
I'm using OptionTree and that will return categories ids with "," between them.
and then I get post with... | To properly understand the difference, you have to dig into the Wordpress Core
* [`is_archive()`](http://codex.wordpress.org/Function_Reference/is_archive) (defined in [wp-includes/query.php#L140](https://core.trac.wordpress.org/browser/tags/3.9.2/src/wp-includes/query.php#L140)) checks any type of archive page. These... |
157,760 | <p>Guys</p>
<p>How can I get the link and title of both next and previous post on the single page? Just like in the screenshot below.</p>
<p>I try to use this but nothing shows up.</p>
<pre><code>$prev = get_previous_post();
$next = get_next_post();
$prev_title = $prev ? get_the_title($prev) : 'Current is First Post... | [
{
"answer_id": 157761,
"author": "karpstrucking",
"author_id": 55214,
"author_profile": "https://wordpress.stackexchange.com/users/55214",
"pm_score": 2,
"selected": false,
"text": "<p>I believe what you want are the <a href=\"http://codex.wordpress.org/Template_Tags/previous_post_link\"... | 2014/08/14 | [
"https://wordpress.stackexchange.com/questions/157760",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57284/"
] | Guys
How can I get the link and title of both next and previous post on the single page? Just like in the screenshot below.
I try to use this but nothing shows up.
```
$prev = get_previous_post();
$next = get_next_post();
$prev_title = $prev ? get_the_title($prev) : 'Current is First Post';
$next_title = $next ? get... | I believe what you want are the [`previous_post_link()`](http://codex.wordpress.org/Template_Tags/previous_post_link) and [`next_post_link()`](http://codex.wordpress.org/Template_Tags/next_post_link) functions. |
157,829 | <p>I understand that to create a new page template, all I have to do is create my custom template (in this case, <code>page-custom.php</code>) file, and save it in <code>wp-content/themes/mytheme/</code>.</p>
<p>However, where can I access this newly created template file? I want to edit it now... but it does not show... | [
{
"answer_id": 157830,
"author": "Mr.Happy",
"author_id": 44300,
"author_profile": "https://wordpress.stackexchange.com/users/44300",
"pm_score": 3,
"selected": true,
"text": "<p>May be something is wrong on your page template file. Have your added page template name at top of the page l... | 2014/08/14 | [
"https://wordpress.stackexchange.com/questions/157829",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57911/"
] | I understand that to create a new page template, all I have to do is create my custom template (in this case, `page-custom.php`) file, and save it in `wp-content/themes/mytheme/`.
However, where can I access this newly created template file? I want to edit it now... but it does not show up the page editor's Page Attri... | May be something is wrong on your page template file. Have your added page template name at top of the page like this:
```
<?php
/*
Template Name: My Custom Page
*/
```
Try with this and check once again. You can check WordPress document for creating custom page template. Check this link: [Page Templates](http://cod... |
157,835 | <p>I'm really unexperienced when it comes to conditonal statements with php and unfortunately the documentation of Advanced Custom Fields isn't covering this topic as fair as I know. But anyway, what I'm trying to do is to display some markup and custom fields but only if one of the fields or both fields have data.</p>... | [
{
"answer_id": 157837,
"author": "Josh Mountain",
"author_id": 27454,
"author_profile": "https://wordpress.stackexchange.com/users/27454",
"pm_score": 3,
"selected": true,
"text": "<p>I believe you are on the right track with your second idea there, but you have some syntax errors with y... | 2014/08/14 | [
"https://wordpress.stackexchange.com/questions/157835",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28103/"
] | I'm really unexperienced when it comes to conditonal statements with php and unfortunately the documentation of Advanced Custom Fields isn't covering this topic as fair as I know. But anyway, what I'm trying to do is to display some markup and custom fields but only if one of the fields or both fields have data.
For e... | I believe you are on the right track with your second idea there, but you have some syntax errors with your conditional. In PHP all of your logic should be wrapped inside one set of `( )` for your conditional. Try this:
```
<?php
if ( get_field('website') || get_field('emailaddress') ) {
?>
<footer>
<?... |
157,845 | <p>I am pretty new in WordPress theme development and I am finding 2 problem with this <strong>posts archive page</strong>: <a href="http://lnx.asper-eritrea.com/archivio/" rel="nofollow">http://lnx.asper-eritrea.com/archivio/</a></p>
<p>The previous page have to show ALL the blog posts into an unordered list.</p>
<p... | [
{
"answer_id": 157849,
"author": "Tomás Cot",
"author_id": 57843,
"author_profile": "https://wordpress.stackexchange.com/users/57843",
"pm_score": 0,
"selected": false,
"text": "<p>Try this:</p>\n\n<pre><code>query_posts( 'posts_per_page=-1' );\n</code></pre>\n\n<p>Just a head up, you sh... | 2014/08/14 | [
"https://wordpress.stackexchange.com/questions/157845",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29275/"
] | I am pretty new in WordPress theme development and I am finding 2 problem with this **posts archive page**: <http://lnx.asper-eritrea.com/archivio/>
The previous page have to show ALL the blog posts into an unordered list.
The main problem is that are shown only the last 10 published posts.
The other problem is rela... | WordPress by default will only load 10 posts. That can be changed in the admin under Settings->Reading and then setting the amount beside "Blog pages show at most".
You can override that number in your custom queries a couple of ways but I would first recommend against the use of [query\_posts()](http://codex.wordpres... |
157,869 | <p>I want to add iOs, Android and favourite icons to the website. Generally I udnerstand how they shold be implomented: link files in the head section and you good to go, however there are many lines (for both devices and favico makes more than 10), so I do not know how to add them correctly: </p>
<ol>
<li>Somehow enq... | [
{
"answer_id": 157877,
"author": "Welcher",
"author_id": 27210,
"author_profile": "https://wordpress.stackexchange.com/users/27210",
"pm_score": 3,
"selected": true,
"text": "<p>Hook into <a href=\"http://codex.wordpress.org/Plugin_API/Action_Reference/wp_head\" rel=\"nofollow\">wp_head<... | 2014/08/14 | [
"https://wordpress.stackexchange.com/questions/157869",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57934/"
] | I want to add iOs, Android and favourite icons to the website. Generally I udnerstand how they shold be implomented: link files in the head section and you good to go, however there are many lines (for both devices and favico makes more than 10), so I do not know how to add them correctly:
1. Somehow enqueue them in ... | Hook into [wp\_head](http://codex.wordpress.org/Plugin_API/Action_Reference/wp_head) in your functions.php file.
```
add_action('wp_head', 'add_your_stuff');
function add_your_stuff() {
?>
<link rel="shortcut icon" href="<?php echo get_stylesheet_directory_uri();?>/favicon.ico" type="image/x-icon" />
<lin... |
157,880 | <p>I have a custom table called "tags" that contains a <code>charity_id</code> that is a reference to a post ID ... I need to query the "tags" table to grab this <code>charity_id</code> and then pull in the post title and a few of the meta data.</p>
<p>Ideally, the end result would produce the following:</p>
<pre><co... | [
{
"answer_id": 157954,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": true,
"text": "<p>I'm posting my comment to @MarkKaplun as part of my answer. </p>\n\n<blockquote>\n <p>My point is this,... | 2014/08/14 | [
"https://wordpress.stackexchange.com/questions/157880",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9295/"
] | I have a custom table called "tags" that contains a `charity_id` that is a reference to a post ID ... I need to query the "tags" table to grab this `charity_id` and then pull in the post title and a few of the meta data.
Ideally, the end result would produce the following:
```
tags.serial_number, post.title, post_met... | I'm posting my comment to @MarkKaplun as part of my answer.
>
> My point is this, every end user experience a certain thing in a certain way based on his/her own knowledge, experience, usability and personal preference. There can never be a wrong or right answer here. Option one might suite you best, option two migh... |
157,881 | <p>The following code works fine for me:</p>
<pre><code>$term = get_term_by('slug', ‘foo’, 'post_tag');
$args = array (
'posts_per_page' => 5,
'paged' => $paged,
'post__not_in' => get_option( 'sticky_posts' ) ,
'tag__not_in' => $term
);
</code></pre>
<p>I'd now like to <code>get_term_by</... | [
{
"answer_id": 157954,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": true,
"text": "<p>I'm posting my comment to @MarkKaplun as part of my answer. </p>\n\n<blockquote>\n <p>My point is this,... | 2014/08/14 | [
"https://wordpress.stackexchange.com/questions/157881",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58197/"
] | The following code works fine for me:
```
$term = get_term_by('slug', ‘foo’, 'post_tag');
$args = array (
'posts_per_page' => 5,
'paged' => $paged,
'post__not_in' => get_option( 'sticky_posts' ) ,
'tag__not_in' => $term
);
```
I'd now like to `get_term_by` multiple tags, e.g., 'foo' and 'bar' (I'm t... | I'm posting my comment to @MarkKaplun as part of my answer.
>
> My point is this, every end user experience a certain thing in a certain way based on his/her own knowledge, experience, usability and personal preference. There can never be a wrong or right answer here. Option one might suite you best, option two migh... |
157,906 | <p>I can't get my head around this. I get this error:</p>
<p><code>Parse error: syntax error, unexpected '"' in 224.</code> The line is this between <code>foreach</code> <code>$html</code>:</p>
<pre><code>$html = '';
foreach ( $recent_across_network as $post ) {
$html .= 'blog_id, $post->ID ) . '">' . ... | [
{
"answer_id": 157913,
"author": "Welcher",
"author_id": 27210,
"author_profile": "https://wordpress.stackexchange.com/users/27210",
"pm_score": 2,
"selected": false,
"text": "<p>These look like 2 separate questions.</p>\n\n<p>The first I think is a single vs double quotes issue:</p>\n\n... | 2014/08/14 | [
"https://wordpress.stackexchange.com/questions/157906",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50638/"
] | I can't get my head around this. I get this error:
`Parse error: syntax error, unexpected '"' in 224.` The line is this between `foreach` `$html`:
```
$html = '';
foreach ( $recent_across_network as $post ) {
$html .= 'blog_id, $post->ID ) . '">' . $post->post_title . '';
}
$html .= '';
```
Also I ge... | These look like 2 separate questions.
The first I think is a single vs double quotes issue:
Try this:
```
$html = '';
foreach ( $recent_across_network as $post ) {
$html .= 'blog_id, '.$post->ID.' ) . '">' . $post->post_title . '';
}
$html .= '';
```
The line in the foreach is putting $post->ID in single quote... |
157,907 | <p>I am very new in WordPress development and I have a doubt about the WP database table named <strong>posts</strong></p>
<p>I have observe that when I create a new post (into the WP administration panel) are created 2 record into the <strong>posts</strong> table.</p>
<p>For example, after that I have create a single... | [
{
"answer_id": 157911,
"author": "sakibmoon",
"author_id": 23214,
"author_profile": "https://wordpress.stackexchange.com/users/23214",
"pm_score": 2,
"selected": true,
"text": "<p>The second one is revision. It means the changes that you made, but didn't save. Wordpress saves that as rev... | 2014/08/14 | [
"https://wordpress.stackexchange.com/questions/157907",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29275/"
] | I am very new in WordPress development and I have a doubt about the WP database table named **posts**
I have observe that when I create a new post (into the WP administration panel) are created 2 record into the **posts** table.
For example, after that I have create a single post titled as **DB TEST** into the **post... | The second one is revision. It means the changes that you made, but didn't save. Wordpress saves that as revision post. There might be more than one revision post if you make more changes without updating the post.
You don't need to worry about that. It's all in background and won't affect you in any way. |
157,909 | <p>I created two new WordPress RSS feeds in my theme functions:
<code><pre>
// Custom Feed 1
add_action('init', 'customRSS');
function customRSS(){
add_feed('feedname', 'customRSSFunc');
}
function customRSSFunc(){
get_template_part('rss', 'feedname');
}</p>
<p>// Custom Feed 2
add_action('init', 'customRSS2');
funct... | [
{
"answer_id": 157911,
"author": "sakibmoon",
"author_id": 23214,
"author_profile": "https://wordpress.stackexchange.com/users/23214",
"pm_score": 2,
"selected": true,
"text": "<p>The second one is revision. It means the changes that you made, but didn't save. Wordpress saves that as rev... | 2014/08/14 | [
"https://wordpress.stackexchange.com/questions/157909",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25552/"
] | I created two new WordPress RSS feeds in my theme functions:
````
// Custom Feed 1
add_action('init', 'customRSS');
function customRSS(){
add_feed('feedname', 'customRSSFunc');
}
function customRSSFunc(){
get_template_part('rss', 'feedname');
}
````
// Custom Feed 2
add\_action('init', 'customRSS2');
function custom... | The second one is revision. It means the changes that you made, but didn't save. Wordpress saves that as revision post. There might be more than one revision post if you make more changes without updating the post.
You don't need to worry about that. It's all in background and won't affect you in any way. |
157,933 | <p>I'm using a starter theme that was provided to me by a friend, and have successfully implemented jQuery several times on the website. I want a background image inside a div to change when the user click a li in the menu.</p>
<pre><code><ul class="mainNav">
<?php wp_nav_menu( array( 'container' => f... | [
{
"answer_id": 157911,
"author": "sakibmoon",
"author_id": 23214,
"author_profile": "https://wordpress.stackexchange.com/users/23214",
"pm_score": 2,
"selected": true,
"text": "<p>The second one is revision. It means the changes that you made, but didn't save. Wordpress saves that as rev... | 2014/08/14 | [
"https://wordpress.stackexchange.com/questions/157933",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58211/"
] | I'm using a starter theme that was provided to me by a friend, and have successfully implemented jQuery several times on the website. I want a background image inside a div to change when the user click a li in the menu.
```
<ul class="mainNav">
<?php wp_nav_menu( array( 'container' => false, 'theme_location' => '... | The second one is revision. It means the changes that you made, but didn't save. Wordpress saves that as revision post. There might be more than one revision post if you make more changes without updating the post.
You don't need to worry about that. It's all in background and won't affect you in any way. |
157,958 | <p>How to make redirection on WordPress site with .htaccess to redirect this:</p>
<p><a href="http://www.my-site.com/page/n" rel="nofollow">http://www.my-site.com/page/n</a></p>
<p>to home page:</p>
<p><a href="http://www.my-site.com/" rel="nofollow">http://www.my-site.com/</a></p>
<p>I do not wish to list previous... | [
{
"answer_id": 157974,
"author": "Howard E",
"author_id": 57589,
"author_profile": "https://wordpress.stackexchange.com/users/57589",
"pm_score": 3,
"selected": true,
"text": "<p>It looks as though what you're asking is to redirect /page/n to the homepage, this can be accomplished with t... | 2014/08/15 | [
"https://wordpress.stackexchange.com/questions/157958",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25053/"
] | How to make redirection on WordPress site with .htaccess to redirect this:
<http://www.my-site.com/page/n>
to home page:
<http://www.my-site.com/>
I do not wish to list previous post on site on first page of site, I removed paginated links from bottom of index.php but it is possible to open those pages typing addre... | It looks as though what you're asking is to redirect /page/n to the homepage, this can be accomplished with the RedirectMatch directive.
So:
```
RedirectMatch 301 ^/page/(.*) http://www.my-site.com/
```
would redirect all traffic from /page/n to the homepage. |
157,982 | <p>I have tried to include my javascript file in the following way:</p>
<pre><code>function theme_scripts()
{
wp_enqueue_scripts( 'custom-script', get_template_directory_uri() . '/js/menu-fix.js',array('jQuery'), true);
}
add_action('init', 'theme_scripts');
</code></pre>
<p>This file is included in <code>funct... | [
{
"answer_id": 157985,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 1,
"selected": false,
"text": "<p>The dependencies are case-sensitive - you need <code>array( 'jquery' )</code> (no uppercase Q).</p>\n"
}... | 2014/08/15 | [
"https://wordpress.stackexchange.com/questions/157982",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4146/"
] | I have tried to include my javascript file in the following way:
```
function theme_scripts()
{
wp_enqueue_scripts( 'custom-script', get_template_directory_uri() . '/js/menu-fix.js',array('jQuery'), true);
}
add_action('init', 'theme_scripts');
```
This file is included in `functions.php`
But for some reason ... | You're mixing up the [singular `wp_enqueue_script`](http://codex.wordpress.org/Function_Reference/wp_enqueue_script), which adds a script, with the [plural `wp_enqueue_scripts`](http://codex.wordpress.org/Plugin_API/Action_Reference/wp_enqueue_scripts) which is an action and a function that triggers that action. I thin... |
157,993 | <p>I am writing a plugin in which I am adding a custom post type(called 'events') using register_post_type. Additionally I want it to use single-event.php instead of the regular single.php.
The current structure of the plugin folder is :</p>
<ul>
<li>plugin-main-file.php</li>
<li>single-event.php</li>
</ul>
<p>I know... | [
{
"answer_id": 157985,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 1,
"selected": false,
"text": "<p>The dependencies are case-sensitive - you need <code>array( 'jquery' )</code> (no uppercase Q).</p>\n"
}... | 2014/08/15 | [
"https://wordpress.stackexchange.com/questions/157993",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54940/"
] | I am writing a plugin in which I am adding a custom post type(called 'events') using register\_post\_type. Additionally I want it to use single-event.php instead of the regular single.php.
The current structure of the plugin folder is :
* plugin-main-file.php
* single-event.php
I know its possible if I place it insid... | You're mixing up the [singular `wp_enqueue_script`](http://codex.wordpress.org/Function_Reference/wp_enqueue_script), which adds a script, with the [plural `wp_enqueue_scripts`](http://codex.wordpress.org/Plugin_API/Action_Reference/wp_enqueue_scripts) which is an action and a function that triggers that action. I thin... |
157,996 | <p>I have got a site with a sticky header navigation. The problem is that when I am logged in, the <code>wpadminbar</code> falls over the navigation.</p>
<p>The code of my navigation is:</p>
<pre><code><div class="container" id ="main">
<div class="navbar navbar-default navbar-fixed-top">
....
</code... | [
{
"answer_id": 158029,
"author": "Kevin Vess",
"author_id": 48165,
"author_profile": "https://wordpress.stackexchange.com/users/48165",
"pm_score": 3,
"selected": true,
"text": "<p>You should be able to keep the <code>wpadminbar</code> from overlaying your navigation bar by using either ... | 2014/08/15 | [
"https://wordpress.stackexchange.com/questions/157996",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4146/"
] | I have got a site with a sticky header navigation. The problem is that when I am logged in, the `wpadminbar` falls over the navigation.
The code of my navigation is:
```
<div class="container" id ="main">
<div class="navbar navbar-default navbar-fixed-top">
....
```
As you can see I use Bootstrap.
Is there a ... | You should be able to keep the `wpadminbar` from overlaying your navigation bar by using either JavaScript or a combination of `PHP` and `CSS`.
I would add this php to the *header.php* file of your theme:
```
<?php if ( is_admin_bar_showing() ) { ?>
<style>
.my-nav-bar {
position: absolute;
... |
157,997 | <p>I have a domain and one subdomain. The domain has a installed SSL with valid certificate but the subdoamin doesn't have it. I have a link from domain's wordpress header.php file that pointing main page in subdomain. The link supposed to be as HTTP but it was changed to HTTPS. I edit header.php file but after update ... | [
{
"answer_id": 158029,
"author": "Kevin Vess",
"author_id": 48165,
"author_profile": "https://wordpress.stackexchange.com/users/48165",
"pm_score": 3,
"selected": true,
"text": "<p>You should be able to keep the <code>wpadminbar</code> from overlaying your navigation bar by using either ... | 2014/08/09 | [
"https://wordpress.stackexchange.com/questions/157997",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I have a domain and one subdomain. The domain has a installed SSL with valid certificate but the subdoamin doesn't have it. I have a link from domain's wordpress header.php file that pointing main page in subdomain. The link supposed to be as HTTP but it was changed to HTTPS. I edit header.php file but after update the... | You should be able to keep the `wpadminbar` from overlaying your navigation bar by using either JavaScript or a combination of `PHP` and `CSS`.
I would add this php to the *header.php* file of your theme:
```
<?php if ( is_admin_bar_showing() ) { ?>
<style>
.my-nav-bar {
position: absolute;
... |
158,000 | <p>I've added a custom page template where I pull out a list of available jobs from the database.</p>
<p>The page displaying the jobs is called <code>jobs</code>.</p>
<p>I'm using the <code>Ninja forms</code> plugin to add a form on a page called <code>apply.php</code>, which has fields for a job application.</p>
<p... | [
{
"answer_id": 158010,
"author": "Eric Allen",
"author_id": 5831,
"author_profile": "https://wordpress.stackexchange.com/users/5831",
"pm_score": 2,
"selected": false,
"text": "<p>It looks like you can use the <a href=\"http://ninjaforms.com/documentation/developer-api/actions/ninja_form... | 2014/08/15 | [
"https://wordpress.stackexchange.com/questions/158000",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57911/"
] | I've added a custom page template where I pull out a list of available jobs from the database.
The page displaying the jobs is called `jobs`.
I'm using the `Ninja forms` plugin to add a form on a page called `apply.php`, which has fields for a job application.
Now for each job title offered on the jobs page, I want ... | @Eric Allen's answer worked perfectly.
However, I'd gotten in touch with the Ninjaforms folks too, and their answer worked as well, so I'm posting it here too.
They referred me to this: <http://docs.ninjaforms.com/customer/en/portal/articles/1981032-filters-ninja_forms_field?b_id=9172>
So adapting it to my problem, ... |
158,004 | <p>I have the following doubt related to the <strong>posts</strong> table of the WordPress database.</p>
<p>I see that when I create a new post in this table are automatically created 2 new rows.</p>
<pre><code>32 1 2014-08-16 15:07:22 2014-08-16 15:07:22 TEST REVISION TEST REVISION inherit open open ... | [
{
"answer_id": 158007,
"author": "YaFred",
"author_id": 36853,
"author_profile": "https://wordpress.stackexchange.com/users/36853",
"pm_score": 1,
"selected": false,
"text": "<p>If you remove revisions, your blog is going to be identical for the user. Only in the backend, you won't hav... | 2014/08/15 | [
"https://wordpress.stackexchange.com/questions/158004",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29275/"
] | I have the following doubt related to the **posts** table of the WordPress database.
I see that when I create a new post in this table are automatically created 2 new rows.
```
32 1 2014-08-16 15:07:22 2014-08-16 15:07:22 TEST REVISION TEST REVISION inherit open open 31-revision-v1 2014-... | You can also do it this way - plugin free.
Open phpmyadmin, browse over to your wp\_posts table and:
`SELECT * FROM `wp_posts` WHERE post_type="revision";`
to see all the posts, their types and revisions and
`delete from `wp_posts` WHERE post_type="revision"`
Though afraid at first...I did it. And it worked without ... |
158,015 | <p>I've noticed that when I make a request to my <code>robots.txt</code> page, I get it with a <code>crawl delay: 10</code> line added to it. I double-checked the file, and it doesn't have that line, so why does it appear? Is it maybe a strange behaviour of some plugins?</p>
| [
{
"answer_id": 213578,
"author": "Didz",
"author_id": 68666,
"author_profile": "https://wordpress.stackexchange.com/users/68666",
"pm_score": 0,
"selected": false,
"text": "<p>For my website, I had the same issue.</p>\n\n<p>Here's my <code>robots.txt</code> file (without the ''crawl dela... | 2014/08/15 | [
"https://wordpress.stackexchange.com/questions/158015",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58241/"
] | I've noticed that when I make a request to my `robots.txt` page, I get it with a `crawl delay: 10` line added to it. I double-checked the file, and it doesn't have that line, so why does it appear? Is it maybe a strange behaviour of some plugins? | For those who are using WordPress as CMS for their site, you can bypass your web hosting server rules by simply removing your robots.txt file and instead modifying the virtual one generated by WordPress. You just have to add a filter to the functions.php file of your theme.
Here's the code snippet:
```
//* Append dir... |
158,017 | <p><a href="http://codex.wordpress.org/Function_Reference/register_post_type" rel="nofollow">This</a> is from the WordPress site, and I can't find my answer in the documentation. When I issue the <code>register_post_type</code>, how does it know which function to use? I know the <code>init</code> action was populated... | [
{
"answer_id": 158018,
"author": "sakibmoon",
"author_id": 23214,
"author_profile": "https://wordpress.stackexchange.com/users/23214",
"pm_score": 4,
"selected": true,
"text": "<p>You are confusing between function and hook. <code>register_post_type()</code> is a function, not a hook.</p... | 2014/08/15 | [
"https://wordpress.stackexchange.com/questions/158017",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49089/"
] | [This](http://codex.wordpress.org/Function_Reference/register_post_type) is from the WordPress site, and I can't find my answer in the documentation. When I issue the `register_post_type`, how does it know which function to use? I know the `init` action was populated with the custom hook `codex_book_init`, but when I l... | You are confusing between function and hook. `register_post_type()` is a function, not a hook.
When you are using `register_post_type( 'book', $args )`, you are calling the `register_post_type()` function to create a Custom Post Type named `book`.
`register_post_type()` needs to be used on the `init` hook which is fi... |
158,021 | <p>I've added categories to images, so that I can use them to filter images within a portfolio page. Now I'm thinking I need to add the rel attribute to each image that contains its assigned categories. Is this the right approach? If so, how do I add add rel with the applicable categories?</p>
| [
{
"answer_id": 158024,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": true,
"text": "<p>This should work for the <code>rel</code> attribute:</p>\n\n<pre><code>/**\n * Create a rel attribute from the... | 2014/08/15 | [
"https://wordpress.stackexchange.com/questions/158021",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57514/"
] | I've added categories to images, so that I can use them to filter images within a portfolio page. Now I'm thinking I need to add the rel attribute to each image that contains its assigned categories. Is this the right approach? If so, how do I add add rel with the applicable categories? | This should work for the `rel` attribute:
```
/**
* Create a rel attribute from the image categories
*
* @see http://wordpress.stackexchange.com/a/158024/26350
*/
add_filter( 'get_image_tag',
function( $html, $id )
{
$rel = array();
foreach( (array) get_the_category( $id ) as $cat )
... |
158,035 | <p>I'm looking at the <code>get_categories()</code> function in the WordPress codex to see how I can return all of the children of each "root parent" ( categories that have no parents ). For example, if I am interested in the children for multiple "root parents", I'd like to know if there will be more than one instance... | [
{
"answer_id": 158039,
"author": "Benoti",
"author_id": 58141,
"author_profile": "https://wordpress.stackexchange.com/users/58141",
"pm_score": 1,
"selected": false,
"text": "<p>Try to structure your categories with the tax-meta-class <a href=\"http://en.bainternet.info/wordpress-taxonom... | 2014/08/15 | [
"https://wordpress.stackexchange.com/questions/158035",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49643/"
] | I'm looking at the `get_categories()` function in the WordPress codex to see how I can return all of the children of each "root parent" ( categories that have no parents ). For example, if I am interested in the children for multiple "root parents", I'd like to know if there will be more than one instance of the same c... | **No**, a term can have many children, but only a single parent. The parent field in the database can hold only a single value.
It is a hierarchical one to many relationship, not a many to many relationship.
The same is true of posts. A post can have only 1 parent, but many children. To get around that you would use ... |
158,063 | <p>I essentially want to create several different front-page.php templates with different loops and layouts and then present an option in the admin panel to select one template on one day and a different template on another day.</p>
<p>This can be done, I suppose, by fooling Wordpress and selecting a static page to ap... | [
{
"answer_id": 158066,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 1,
"selected": false,
"text": "<p>There is only one option, the page templates one. This is how 99% of the themes work and what wordpress u... | 2014/08/16 | [
"https://wordpress.stackexchange.com/questions/158063",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52431/"
] | I essentially want to create several different front-page.php templates with different loops and layouts and then present an option in the admin panel to select one template on one day and a different template on another day.
This can be done, I suppose, by fooling Wordpress and selecting a static page to appear as th... | One way is to have a single `front-page.php` and then using `get_template_part()`, to show different content based on user choice.
Rough code:
```
get_header();
$layout = get_option( 'front_page_layout', 'default' );
get_template_part( 'front-page', $layout );
get_footer();
```
After that you need to create a fil... |
158,065 | <p>I'll try my best to explain what I'm trying to achieve. I haven't been developing with Wordpress for a while and I've hit a bit of a wall.</p>
<p>I'm looking to get into making Premium Wordpress Themes. Each theme is going to consist of custom post types (e.g. portfolio, slideshow, events). I'm trying to create a S... | [
{
"answer_id": 158066,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 1,
"selected": false,
"text": "<p>There is only one option, the page templates one. This is how 99% of the themes work and what wordpress u... | 2014/08/16 | [
"https://wordpress.stackexchange.com/questions/158065",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58261/"
] | I'll try my best to explain what I'm trying to achieve. I haven't been developing with Wordpress for a while and I've hit a bit of a wall.
I'm looking to get into making Premium Wordpress Themes. Each theme is going to consist of custom post types (e.g. portfolio, slideshow, events). I'm trying to create a SINGLE plug... | One way is to have a single `front-page.php` and then using `get_template_part()`, to show different content based on user choice.
Rough code:
```
get_header();
$layout = get_option( 'front_page_layout', 'default' );
get_template_part( 'front-page', $layout );
get_footer();
```
After that you need to create a fil... |
158,075 | <p>I made a local clone of a website that's running LIVE in order to safely work offline for a while. On every page of the local version I get a HUGE warning which says</p>
<p><strong>Notice: Constant WP_POST_REVISIONS already defined in C:\xampp\htdocs\local-tutorials\wp-config.php on line 95</strong></p>
<p>I guess... | [
{
"answer_id": 305982,
"author": "Mehdi Soltani",
"author_id": 109454,
"author_profile": "https://wordpress.stackexchange.com/users/109454",
"pm_score": 3,
"selected": false,
"text": "<p>I have the same problem before. \nI put <code>WP_POST_REVISIONS</code> in the end of <code>wp-config.... | 2014/08/16 | [
"https://wordpress.stackexchange.com/questions/158075",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28914/"
] | I made a local clone of a website that's running LIVE in order to safely work offline for a while. On every page of the local version I get a HUGE warning which says
**Notice: Constant WP\_POST\_REVISIONS already defined in C:\xampp\htdocs\local-tutorials\wp-config.php on line 95**
I guess it's been defined twice, on... | I have the same problem before.
I put `WP_POST_REVISIONS` in the end of `wp-config.php` file and it didn't work correctly.
You should put your codes before defining `ABSPATH` and before this line:
```
/* That's all, stop editing! Happy blogging. */
```
it must be something like in the following:
```
define( 'WP_P... |
158,095 | <p>What I would like to do is have a list of users who have contributed at least one post.</p>
<p>I need to show the following: </p>
<p><strong>[User photo] | [User Name] | [User post count]</strong></p>
<p>e.g.</p>
<p><strong>[photo] Joe Bloggs(8)</strong> </p>
<p>I made a start and went down this route:</p>
<pr... | [
{
"answer_id": 158100,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 4,
"selected": true,
"text": "<p>You need to set the <code>who</code> parameter in <a href=\"http://codex.wordpress.org/Function_Referenc... | 2014/08/16 | [
"https://wordpress.stackexchange.com/questions/158095",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58049/"
] | What I would like to do is have a list of users who have contributed at least one post.
I need to show the following:
**[User photo] | [User Name] | [User post count]**
e.g.
**[photo] Joe Bloggs(8)**
I made a start and went down this route:
```
<?php
$blogusers = get_users( 'orderby=post_count' );
fore... | You need to set the `who` parameter in [`get_users`](http://codex.wordpress.org/Function_Reference/get_users)
```
<?php
$blogusers = get_users( 'orderby=post_count&who=authors' );
foreach ( $blogusers as $user ) {
echo '<li>' . esc_html( $user->display_name ) . '</li>';
}
?>
```
**EDIT**
Seems I w... |
158,116 | <p>I'm working on a child theme of the Toolset Bootstrap Theme.
I need to create a custom sidebar, so I registered the new sidebar in my child theme's function.php file: </p>
<pre><code>function wpbootstrap_register_newsidebar() {
/* Register the new sidebar. */
register_sidebar(
array(
'id' => 'sideba... | [
{
"answer_id": 158134,
"author": "Howard E",
"author_id": 57589,
"author_profile": "https://wordpress.stackexchange.com/users/57589",
"pm_score": 1,
"selected": false,
"text": "<p>This seems to test properly for me.</p>\n\n<pre><code>function register_home_sidebar() {\n\n/* Register the ... | 2014/08/16 | [
"https://wordpress.stackexchange.com/questions/158116",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58272/"
] | I'm working on a child theme of the Toolset Bootstrap Theme.
I need to create a custom sidebar, so I registered the new sidebar in my child theme's function.php file:
```
function wpbootstrap_register_newsidebar() {
/* Register the new sidebar. */
register_sidebar(
array(
'id' => 'sidebar-999',
'... | Ok, finally the support team answered my question, and if even if there's not a real solution, suggested a workaround. Since the answer is buried deep in the vendor user forum - [link here](http://wp-types.com/forums/topic/widgets-disappearing/) - I'm sharing the solution here, just in case someone has the same problem... |
158,147 | <p>How can I remove some of the allowed HTML tags in comments/posts? For whatever reason, the following code, placed in my theme's <code>functions.php</code>, didn't work:</p>
<pre><code>add_action('init', 'my_html_tags_code', 10);
function my_html_tags_code() {
define('CUSTOM_TAGS', true);
global $allowedpost... | [
{
"answer_id": 158149,
"author": "sakibmoon",
"author_id": 23214,
"author_profile": "https://wordpress.stackexchange.com/users/23214",
"pm_score": 0,
"selected": false,
"text": "<p>Try hooking to a later hook for comment tags.</p>\n\n<pre><code>function my_comment_tags() {\n global $a... | 2014/08/17 | [
"https://wordpress.stackexchange.com/questions/158147",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25959/"
] | How can I remove some of the allowed HTML tags in comments/posts? For whatever reason, the following code, placed in my theme's `functions.php`, didn't work:
```
add_action('init', 'my_html_tags_code', 10);
function my_html_tags_code() {
define('CUSTOM_TAGS', true);
global $allowedposttags, $allowedtags;
$... | There's a filter-hook that allows you to run some checking before comment is posted so you could use it too :
```
add_filter('preprocess_comment', 'wpse_158147_check_new_comment');
function wpse_158147_check_new_comment($commentdata){
$commentdata['comment_content'] = preg_replace("/<tag(.*?)>(.*)<\/tag>/", "$2",... |
158,152 | <p>I'm curretnly developing my web store using the Easy digital downalod plugin.
Now my problem is that i'd like to show only the list of a subcategory and i can't seem to find a way to do so. I ran across a this snippet from sumobi:</p>
<pre><code><?php
/**
* Output a list of EDD's terms (with links) from the 'do... | [
{
"answer_id": 158170,
"author": "Alex Dumitru",
"author_id": 5810,
"author_profile": "https://wordpress.stackexchange.com/users/5810",
"pm_score": 1,
"selected": false,
"text": "<p>You can get only the category's children.</p>\n\n<pre><code>$terms = get_terms( $taxonomy, 'child_of=6' );... | 2014/08/17 | [
"https://wordpress.stackexchange.com/questions/158152",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58287/"
] | I'm curretnly developing my web store using the Easy digital downalod plugin.
Now my problem is that i'd like to show only the list of a subcategory and i can't seem to find a way to do so. I ran across a this snippet from sumobi:
```
<?php
/**
* Output a list of EDD's terms (with links) from the 'download_category' ... | You can get only the category's children.
```
$terms = get_terms( $taxonomy, 'child_of=6' );
``` |
158,153 | <p>I have the following code displaying posts from a custom post type. However, I need them displayed in date order from information put in a custom field, can this be done?</p>
<p>I try this code :-</p>
<pre><code>$course = new WP_Query(
array (
'posts_per_page' => '10' ,
'post_type' => ... | [
{
"answer_id": 158154,
"author": "sakibmoon",
"author_id": 23214,
"author_profile": "https://wordpress.stackexchange.com/users/23214",
"pm_score": 2,
"selected": false,
"text": "<p>Use <code>meta_value</code> instead of <code>meta_value_num</code></p>\n\n<pre><code><?php $course = ... | 2014/08/17 | [
"https://wordpress.stackexchange.com/questions/158153",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52632/"
] | I have the following code displaying posts from a custom post type. However, I need them displayed in date order from information put in a custom field, can this be done?
I try this code :-
```
$course = new WP_Query(
array (
'posts_per_page' => '10' ,
'post_type' => 'course',
'orderby'... | Use `meta_value` instead of `meta_value_num`
```
<?php $course = new wp_query( array ( 'posts_per_page' => '10' ,
'post_type' => 'course',
'orderby' => 'meta_value',
'meta_key' => 'course_date'... |
158,175 | <p>I have set my category navigation menu to display home and 5 of my categories and their respective posts when the category tab is clicked, as that is all the space there is to display in the menu bar.</p>
<p>I have more than 20 categories and I want the 5 category tabs to randomly display the categories on each bro... | [
{
"answer_id": 158154,
"author": "sakibmoon",
"author_id": 23214,
"author_profile": "https://wordpress.stackexchange.com/users/23214",
"pm_score": 2,
"selected": false,
"text": "<p>Use <code>meta_value</code> instead of <code>meta_value_num</code></p>\n\n<pre><code><?php $course = ... | 2014/08/17 | [
"https://wordpress.stackexchange.com/questions/158175",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58294/"
] | I have set my category navigation menu to display home and 5 of my categories and their respective posts when the category tab is clicked, as that is all the space there is to display in the menu bar.
I have more than 20 categories and I want the 5 category tabs to randomly display the categories on each browser refre... | Use `meta_value` instead of `meta_value_num`
```
<?php $course = new wp_query( array ( 'posts_per_page' => '10' ,
'post_type' => 'course',
'orderby' => 'meta_value',
'meta_key' => 'course_date'... |
158,179 | <p>I have this plugin "DWQA" in which the ajax calls work perfectly fine when the user is not logged into the site.
But the moment user logs in to the site the ajax calls dont work.
The variables that are passed to the admin-ajax.php return null.</p>
<p>How does ajax call differ in wordpress in case of logged in and l... | [
{
"answer_id": 158180,
"author": "Alex Dumitru",
"author_id": 5810,
"author_profile": "https://wordpress.stackexchange.com/users/5810",
"pm_score": 0,
"selected": false,
"text": "<p>It might be due to another plugin that affects your website only to logged in users. Try to disable them o... | 2014/08/17 | [
"https://wordpress.stackexchange.com/questions/158179",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57736/"
] | I have this plugin "DWQA" in which the ajax calls work perfectly fine when the user is not logged into the site.
But the moment user logs in to the site the ajax calls dont work.
The variables that are passed to the admin-ajax.php return null.
How does ajax call differ in wordpress in case of logged in and logged out ... | Probably it's because of this:
```
add_action( 'wp_ajax_my_action', 'my_action_callback' );
add_action( 'wp_ajax_nopriv_my_action', 'my_action_callback' );
```
You have to add the action for both hooks. Probably the plugin is hooked to the second hook right now.
You can [read more in the docs](https://codex.wordpre... |
158,182 | <p>I have got a little problem. I am working in a theme developed by someone I don´t know.</p>
<p>I was testing the site in my cellphone and saw the_content() function does not show anything. I checked in one Ipad and it's working.</p>
<p>I also checked my functions.php and I did not see anything weird.</p>
<p>This ... | [
{
"answer_id": 158180,
"author": "Alex Dumitru",
"author_id": 5810,
"author_profile": "https://wordpress.stackexchange.com/users/5810",
"pm_score": 0,
"selected": false,
"text": "<p>It might be due to another plugin that affects your website only to logged in users. Try to disable them o... | 2014/08/17 | [
"https://wordpress.stackexchange.com/questions/158182",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58297/"
] | I have got a little problem. I am working in a theme developed by someone I don´t know.
I was testing the site in my cellphone and saw the\_content() function does not show anything. I checked in one Ipad and it's working.
I also checked my functions.php and I did not see anything weird.
This is the link (sorry beca... | Probably it's because of this:
```
add_action( 'wp_ajax_my_action', 'my_action_callback' );
add_action( 'wp_ajax_nopriv_my_action', 'my_action_callback' );
```
You have to add the action for both hooks. Probably the plugin is hooked to the second hook right now.
You can [read more in the docs](https://codex.wordpre... |
158,190 | <p>I am trying to set it so that the person who created a Page is the ONLY one who can comment on that particular page. This will be a logged in person. I haven't had any luck with Role Editor Plugins. </p>
| [
{
"answer_id": 158180,
"author": "Alex Dumitru",
"author_id": 5810,
"author_profile": "https://wordpress.stackexchange.com/users/5810",
"pm_score": 0,
"selected": false,
"text": "<p>It might be due to another plugin that affects your website only to logged in users. Try to disable them o... | 2014/08/17 | [
"https://wordpress.stackexchange.com/questions/158190",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57398/"
] | I am trying to set it so that the person who created a Page is the ONLY one who can comment on that particular page. This will be a logged in person. I haven't had any luck with Role Editor Plugins. | Probably it's because of this:
```
add_action( 'wp_ajax_my_action', 'my_action_callback' );
add_action( 'wp_ajax_nopriv_my_action', 'my_action_callback' );
```
You have to add the action for both hooks. Probably the plugin is hooked to the second hook right now.
You can [read more in the docs](https://codex.wordpre... |
158,248 | <p>On my WordPress 3.9.2 installation can I extract the users plain text passwords by going to Users, select all users, and choosing Bulk Actions Export.</p>
<p>When I look in the mySQL database with phpMyAdmin, the passwords are hashed.</p>
<p><strong>Question</strong></p>
<p>How come all user passwords can be expo... | [
{
"answer_id": 158472,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 5,
"selected": true,
"text": "<p>You cannot export passwords as plaintext in WordPress, because they are not stored in plaintext. What you see here is ... | 2014/08/18 | [
"https://wordpress.stackexchange.com/questions/158248",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58343/"
] | On my WordPress 3.9.2 installation can I extract the users plain text passwords by going to Users, select all users, and choosing Bulk Actions Export.
When I look in the mySQL database with phpMyAdmin, the passwords are hashed.
**Question**
How come all user passwords can be exported in plain text, and how can I pre... | You cannot export passwords as plaintext in WordPress, because they are not stored in plaintext. What you see here is obviously the result of a very bad plugin.
Fields like `Payment`, `Sex` or `Company` are not even part of the regular WordPress tables.
For the future: Do not install plugins without prior tests and r... |
158,285 | <p>I am having an issue finding out how to display the number of plugins/updates available to call somewhere else other than the admin header. I found the function <code>wp_get_update_data</code> should be what I need:</p>
<p><a href="https://wordpress.stackexchange.com/questions/62216/how-is-the-wp-get-update-data-fu... | [
{
"answer_id": 158288,
"author": "sakibmoon",
"author_id": 23214,
"author_profile": "https://wordpress.stackexchange.com/users/23214",
"pm_score": 3,
"selected": false,
"text": "<p><a href=\"http://wpseek.com/wp_get_update_data/\">wp_get_update_data()</a> returns an array in this format<... | 2014/08/18 | [
"https://wordpress.stackexchange.com/questions/158285",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32869/"
] | I am having an issue finding out how to display the number of plugins/updates available to call somewhere else other than the admin header. I found the function `wp_get_update_data` should be what I need:
[How is the " wp\_get\_update\_data " function used?](https://wordpress.stackexchange.com/questions/62216/how-is-t... | Here's an example of the data returned from the `wp_get_update_data()` function:
```
Array
(
[counts] => Array
(
[plugins] => 3
[themes] => 2
[wordpress] => 0
[translations] => 0
[total] => 5
)
[title] => 3 Plugin Updates, 2 Theme Upd... |
158,296 | <p>How do I provide two different personalized messages for two different password-protected pages? I'm able to personalize the default message using the code below, but I'm not sure how to add a second unique message for visitors to a second password-protected page. I assume I would add some conditional code in my fun... | [
{
"answer_id": 158299,
"author": "BA_Webimax",
"author_id": 44566,
"author_profile": "https://wordpress.stackexchange.com/users/44566",
"pm_score": 2,
"selected": true,
"text": "<p>You should probably add in more checks, but this should get you started.</p>\n\n<pre><code>function change_... | 2014/08/18 | [
"https://wordpress.stackexchange.com/questions/158296",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58352/"
] | How do I provide two different personalized messages for two different password-protected pages? I'm able to personalize the default message using the code below, but I'm not sure how to add a second unique message for visitors to a second password-protected page. I assume I would add some conditional code in my functi... | You should probably add in more checks, but this should get you started.
```
function change_pw_text($content) {
// Just to save processing other pages.
if ( !is_page('page-slug-one') && !is_page('page-slug-two') )
return $content;
$find = 'This post is password protected. To view it please enter... |
158,303 | <p>I'm having an issue where events that I have scheduled work for a while then just stop. After looking at the event queue I see that the scheduled events are no longer in the queue.</p>
<p>If I deactivate then reactivate the plugin the schedule is back and works for a period of time.</p>
<p>I don't know if WordPres... | [
{
"answer_id": 167677,
"author": "kel",
"author_id": 2832,
"author_profile": "https://wordpress.stackexchange.com/users/2832",
"pm_score": 1,
"selected": false,
"text": "<p>After pouring all of my points into this question and trying a few suggested options it seems that WordPress can't ... | 2014/08/18 | [
"https://wordpress.stackexchange.com/questions/158303",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2832/"
] | I'm having an issue where events that I have scheduled work for a while then just stop. After looking at the event queue I see that the scheduled events are no longer in the queue.
If I deactivate then reactivate the plugin the schedule is back and works for a period of time.
I don't know if WordPress has something t... | My solution for now is check every hour if it is running and if not reschedule it. I also remove this in deactivate etc.
```
wp_schedule_event(time(), 'hourly', 'my_restart_schedule_if_failed');
function my_restart_schedule_if_failed() {
if( !wp_next_scheduled( 'my_scheduled_minute_job' ) ) {
wp_schedule_... |
158,323 | <p>I'm trying to insert posts using a cron job, but I keep running into errors where WP is missing functions (<code>is_user_logged_in</code>, <code>wp_get_current_user</code>).</p>
<p>Is there a proper way to run wp_insert_post using a cron job?</p>
<p>This is the code I have so far.</p>
<p><code>phrets_hourly</code... | [
{
"answer_id": 158809,
"author": "nathanaelphilip",
"author_id": 40502,
"author_profile": "https://wordpress.stackexchange.com/users/40502",
"pm_score": 2,
"selected": false,
"text": "<p>For those who stumble upon this later, use either option 1 or 2 found here: <a href=\"https://core.tr... | 2014/08/18 | [
"https://wordpress.stackexchange.com/questions/158323",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40502/"
] | I'm trying to insert posts using a cron job, but I keep running into errors where WP is missing functions (`is_user_logged_in`, `wp_get_current_user`).
Is there a proper way to run wp\_insert\_post using a cron job?
This is the code I have so far.
`phrets_hourly` is the WP\_CRON hook
```
add_action('phrets_hourly',... | For those who stumble upon this later, use either option 1 or 2 found here: <https://core.trac.wordpress.org/ticket/19373>.
“For other developers who run into this and need to work around it, either of these 2 options work:
call wp\_set\_post\_terms() to add your taxonomies after calling wp\_insert\_post()
set up a "c... |