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 |
|---|---|---|---|---|---|---|
177,676 | <p>I am trying to override wp menu markup and add additional div around each sub-menu ul. </p>
<p>Something like this</p>
<pre><code><ul>
<li><a>Coffee</li>
<li><a>Tea</a>
<div class="holder">
<ul class="sub-menu">
<l... | [
{
"answer_id": 177679,
"author": "jdm2112",
"author_id": 45202,
"author_profile": "https://wordpress.stackexchange.com/users/45202",
"pm_score": 1,
"selected": false,
"text": "<p>I believe what you are looking for is a custom nav walker to control your HTML structure.</p>\n\n<p>The WP Co... | 2015/02/10 | [
"https://wordpress.stackexchange.com/questions/177676",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67176/"
] | I am trying to override wp menu markup and add additional div around each sub-menu ul.
Something like this
```
<ul>
<li><a>Coffee</li>
<li><a>Tea</a>
<div class="holder">
<ul class="sub-menu">
<li><a>Black tea</a></li>
<li><a>Green tea</a></li>
... | OK got it. For anyone who needs to do this , it is best you extend Walker\_Nav\_Menu class if you just need to add things to existing wp menu structure. Otherwise if you are extending Walker class you kinda have to rebuild the menu completely.
Include this class
```
class Walker_Extend_Menu extends Walker_Nav_Menu ... |
177,677 | <p>I have created a custom template and trying to get a custom post of type "song", But it is displaying only the header and footer on the page. There is no post content coming. Even if I try to call general posts then also no content coming, Should I register this template anywhere in the theme? OR need to ... | [
{
"answer_id": 177680,
"author": "vcamargo",
"author_id": 60070,
"author_profile": "https://wordpress.stackexchange.com/users/60070",
"pm_score": -1,
"selected": false,
"text": "<p>Have you tried <code>'post_type'=> 'songs'</code>?</p>\n\n<p>Reference: <a href=\"http://codex.wordpress... | 2015/02/10 | [
"https://wordpress.stackexchange.com/questions/177677",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63934/"
] | I have created a custom template and trying to get a custom post of type "song", But it is displaying only the header and footer on the page. There is no post content coming. Even if I try to call general posts then also no content coming, Should I register this template anywhere in the theme? OR need to call anything ... | You really have two major flaws in your code:
* `query_posts` needs to go before your loop, not inside it
* Never use `query_posts` in the first place unless you need to break something on your page
To learn why not to use `query_posts` and when to use a custom query and how to use it, check [this post](https://wordp... |
177,692 | <p>I'm trying to track down why menu switching by language in the polylang filter is not working correctly.</p>
<p>I'm looking at the function nav_menu_locations which is added as a filter as such:</p>
<pre><code>add_filter('theme_mod_nav_menu_locations', array($this, 'nav_menu_locations'), 20);
</code></pre>
<p>and... | [
{
"answer_id": 177680,
"author": "vcamargo",
"author_id": 60070,
"author_profile": "https://wordpress.stackexchange.com/users/60070",
"pm_score": -1,
"selected": false,
"text": "<p>Have you tried <code>'post_type'=> 'songs'</code>?</p>\n\n<p>Reference: <a href=\"http://codex.wordpress... | 2015/02/10 | [
"https://wordpress.stackexchange.com/questions/177692",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35739/"
] | I'm trying to track down why menu switching by language in the polylang filter is not working correctly.
I'm looking at the function nav\_menu\_locations which is added as a filter as such:
```
add_filter('theme_mod_nav_menu_locations', array($this, 'nav_menu_locations'), 20);
```
and then defined subsequently as:
... | You really have two major flaws in your code:
* `query_posts` needs to go before your loop, not inside it
* Never use `query_posts` in the first place unless you need to break something on your page
To learn why not to use `query_posts` and when to use a custom query and how to use it, check [this post](https://wordp... |
177,703 | <p>Every now and then some clients have multiple domains for the same site. For example domain.com and domain.org. Is it possible to have wordpress work with both domains at the same time? I typically see issues when trying to load resources because of Cross-domain access. I know that I could just point domain.com to d... | [
{
"answer_id": 177704,
"author": "Austin Curtis",
"author_id": 67344,
"author_profile": "https://wordpress.stackexchange.com/users/67344",
"pm_score": 5,
"selected": true,
"text": "<p>Are you wanting for the exact same WordPress site to work on two different domain names, where all links... | 2015/02/10 | [
"https://wordpress.stackexchange.com/questions/177703",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30984/"
] | Every now and then some clients have multiple domains for the same site. For example domain.com and domain.org. Is it possible to have wordpress work with both domains at the same time? I typically see issues when trying to load resources because of Cross-domain access. I know that I could just point domain.com to doma... | Are you wanting for the exact same WordPress site to work on two different domain names, where all links and content would use either domain name?
If this were the case, you would run into [Duplicate Content issues with Google](https://support.google.com/webmasters/answer/66359?hl=en), hurting your SEO pretty badly.
... |
177,723 | <p>I know that the question was already asked but all the answer i found doesnt help me..</p>
<p>I made an HTML page that I would like to integrate in Wordpress.</p>
<p>The integration of the theme was done properly until I get to the posts part</p>
<p>I have a problem with algorithms to display posts so I know it c... | [
{
"answer_id": 177978,
"author": "guidod",
"author_id": 14499,
"author_profile": "https://wordpress.stackexchange.com/users/14499",
"pm_score": 1,
"selected": false,
"text": "<p>[Edit]</p>\n\n<p>If I understand correctly, what you call the \"outer loop\" is just for building a two-column... | 2015/02/10 | [
"https://wordpress.stackexchange.com/questions/177723",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66650/"
] | I know that the question was already asked but all the answer i found doesnt help me..
I made an HTML page that I would like to integrate in Wordpress.
The integration of the theme was done properly until I get to the posts part
I have a problem with algorithms to display posts so I know it comes from the Wordpress ... | [Edit]
If I understand correctly, what you call the "outer loop" is just for building a two-column layout. If so, you don't need to call two WordPress loops, just open a "fake" oeuvres at the beginning, close a "fake" oeuvres at the end, do a single loop (a single while have\_posts()) and close and re-open an oeuvres ... |
177,784 | <p>I am building a more-or-less distinguishing layout which forces me have a header far above the content in the DOM. A structure as follows:</p>
<pre><code><?php get_header(); ?>
<div id="wrapper">
<header class="entry-header" style="background-image:url({url-to-post-thumbnail-of-current-post});"&g... | [
{
"answer_id": 177764,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 2,
"selected": false,
"text": "<p>The difference is that capabilities are part of the access permission system of the site, which utilize a... | 2015/02/11 | [
"https://wordpress.stackexchange.com/questions/177784",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16574/"
] | I am building a more-or-less distinguishing layout which forces me have a header far above the content in the DOM. A structure as follows:
```
<?php get_header(); ?>
<div id="wrapper">
<header class="entry-header" style="background-image:url({url-to-post-thumbnail-of-current-post});">
<h1 class="entry-titl... | There is no one answer, because both have pros and cons depending on what you want to store and why.
A (probably non-exhaustive) list of differences to consider for a choice:
* Capabilities are designed to check if a user can *do* something or not. `user_can` and `current_user_can` are there to help you to check user... |
177,785 | <p>I am trying to apply wordpress filter hook get_the_expert. My intention is to apply filter only when the category slug is "MY-CATEGORY-SLUG". How can I check the category slug inside the filter hook function.</p>
<p>Thanks</p>
| [
{
"answer_id": 177793,
"author": "David Gard",
"author_id": 10097,
"author_profile": "https://wordpress.stackexchange.com/users/10097",
"pm_score": 0,
"selected": false,
"text": "<p>If I have understood your question correctly, this code below should help you (place it in <strong>functio... | 2015/02/11 | [
"https://wordpress.stackexchange.com/questions/177785",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47454/"
] | I am trying to apply wordpress filter hook get\_the\_expert. My intention is to apply filter only when the category slug is "MY-CATEGORY-SLUG". How can I check the category slug inside the filter hook function.
Thanks | Thanks for the response David. I found the solution. I added the following code in functions.php
```
add_filter('get_the_excerpt', 'process_excerpt');
function process_excerpt($param) {
global $post;
if(in_category('MY-CATEGORY-SLUG',$post))
return 'adding some data'.$param;
else
return $p... |
177,823 | <p>I've tried <code>get_site_url();</code>, <code>get_bloginfo('wpurl')</code> and <code>home_url();</code> but they're all giving me a link to the current page rather than the home page.</p>
| [
{
"answer_id": 177824,
"author": "Badger",
"author_id": 66660,
"author_profile": "https://wordpress.stackexchange.com/users/66660",
"pm_score": 1,
"selected": false,
"text": "<p>Just figured out the answer. It needs to be echo'd, so <code>echo site_url</code> works. Or to use in a templa... | 2015/02/11 | [
"https://wordpress.stackexchange.com/questions/177823",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66660/"
] | I've tried `get_site_url();`, `get_bloginfo('wpurl')` and `home_url();` but they're all giving me a link to the current page rather than the home page. | `echo esc_url( home_url( '/' ) );` this best practice.
```
get_bloginfo( $show, $filter );
```
It has lots of Parameters to get info so
let see the **##SHOW(Parameters)**:
name,description,wpurl,url,admin\_email,charset,version,html\_type,text\_direction,language,stylesheet\_url,stylesheet\_directory,template\_url,p... |
177,828 | <p>I have a custom taxonomy which I want to appear under a custom menu. And I achieved that by specifying the custom menu as the parent. Here's the result:</p>
<p><img src="https://i.stack.imgur.com/0Wu5m.png" alt=""></p>
<p>However, when I click on it, the CSV Tag Upload menu collapses, and the taxonomy opens itself... | [
{
"answer_id": 177824,
"author": "Badger",
"author_id": 66660,
"author_profile": "https://wordpress.stackexchange.com/users/66660",
"pm_score": 1,
"selected": false,
"text": "<p>Just figured out the answer. It needs to be echo'd, so <code>echo site_url</code> works. Or to use in a templa... | 2015/02/11 | [
"https://wordpress.stackexchange.com/questions/177828",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67400/"
] | I have a custom taxonomy which I want to appear under a custom menu. And I achieved that by specifying the custom menu as the parent. Here's the result:

However, when I click on it, the CSV Tag Upload menu collapses, and the taxonomy opens itself under the Posts menu:
![enter... | `echo esc_url( home_url( '/' ) );` this best practice.
```
get_bloginfo( $show, $filter );
```
It has lots of Parameters to get info so
let see the **##SHOW(Parameters)**:
name,description,wpurl,url,admin\_email,charset,version,html\_type,text\_direction,language,stylesheet\_url,stylesheet\_directory,template\_url,p... |
177,852 | <p>I changed my WordPress site to use child themes, but the parent theme style has priority over any change I make on the child theme CSS. I can work around it using <code>!important</code>, however this is a patchy solution and the child themes should work as the site's first resource. </p>
<p>For example, in <a href... | [
{
"answer_id": 177858,
"author": "Twodogstar",
"author_id": 67417,
"author_profile": "https://wordpress.stackexchange.com/users/67417",
"pm_score": 0,
"selected": false,
"text": "<p>You can use a more specific selector in your child theme's CSS so that it takes precedence. </p>\n\n<p>So ... | 2015/02/11 | [
"https://wordpress.stackexchange.com/questions/177852",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67414/"
] | I changed my WordPress site to use child themes, but the parent theme style has priority over any change I make on the child theme CSS. I can work around it using `!important`, however this is a patchy solution and the child themes should work as the site's first resource.
For example, in [my site](http://blindalleyc... | Try enqueuing your child theme's CSS like so:
```
// Queue parent style followed by child/customized style
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles', PHP_INT_MAX);
function theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
wp_enqueue_style... |
177,864 | <p>In 'Reading Settings' I have chosen the static-page drop-down menu of a page I created to be the post page. </p>
<p>I've put the html, php, and css from my page.php in index.php to style it. I'm unable to get the featured image. The php I use to get it on page.php isn't working. It's not rendering any html. Also <c... | [
{
"answer_id": 177903,
"author": "Brad Dalton",
"author_id": 9884,
"author_profile": "https://wordpress.stackexchange.com/users/9884",
"pm_score": 0,
"selected": false,
"text": "<p>One example is Twenty Fifteen which uses a template tag in the content.php files like this:</p>\n\n<pre><co... | 2015/02/12 | [
"https://wordpress.stackexchange.com/questions/177864",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/60779/"
] | In 'Reading Settings' I have chosen the static-page drop-down menu of a page I created to be the post page.
I've put the html, php, and css from my page.php in index.php to style it. I'm unable to get the featured image. The php I use to get it on page.php isn't working. It's not rendering any html. Also `<?php the_t... | This is not trivial to do as once you have set a specific page to be an aggregation of posts (being a posts page), wordpress will "forget" the initial information it gets of the page itself and will behave like it was a normal home page of a blog. This means that all the global variables used in the loop will **not** b... |
177,872 | <p>Alright I am starting a music blog and I am working hard at coding up this theme but I am wondering why I can't do this successfully within WordPress when I know for sure it's possible.</p>
<p>Alright so let's say that the first half of the title is the artist name and it's code looks something like what's shown be... | [
{
"answer_id": 177903,
"author": "Brad Dalton",
"author_id": 9884,
"author_profile": "https://wordpress.stackexchange.com/users/9884",
"pm_score": 0,
"selected": false,
"text": "<p>One example is Twenty Fifteen which uses a template tag in the content.php files like this:</p>\n\n<pre><co... | 2015/02/12 | [
"https://wordpress.stackexchange.com/questions/177872",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65897/"
] | Alright I am starting a music blog and I am working hard at coding up this theme but I am wondering why I can't do this successfully within WordPress when I know for sure it's possible.
Alright so let's say that the first half of the title is the artist name and it's code looks something like what's shown below.
```
... | This is not trivial to do as once you have set a specific page to be an aggregation of posts (being a posts page), wordpress will "forget" the initial information it gets of the page itself and will behave like it was a normal home page of a blog. This means that all the global variables used in the loop will **not** b... |
177,908 | <p>Is it possible with the standard build-in tools in Wordpress to get <code>wp_query</code> to only return the count of an query?</p>
<p>Right now, I’ve a query which has several meta_queries but what the only thing I’m interested in is the actually count of the query. </p>
<p>I know that I can use the found_posts ... | [
{
"answer_id": 177910,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 5,
"selected": true,
"text": "<p>There is no build in function to achieve what you want, at least not for complicated meta queries like t... | 2015/02/12 | [
"https://wordpress.stackexchange.com/questions/177908",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6751/"
] | Is it possible with the standard build-in tools in Wordpress to get `wp_query` to only return the count of an query?
Right now, I’ve a query which has several meta\_queries but what the only thing I’m interested in is the actually count of the query.
I know that I can use the found\_posts property but the query itse... | There is no build in function to achieve what you want, at least not for complicated meta queries like this. If you need to use build in functions for this, the best will be to make use of `WP_Query`.
To make the query faster and to skip the unwanted returned array of `WP_Post` properties, and because you are only in... |
177,919 | <p>I'm just starting out with making plugins and I'm trying to make a simple one that will mail a notification to subscribers whenever I publish a new post.</p>
<p>My code so far:</p>
<pre><code>add_action( 'publish_post', 'vb_esa_update_email' );
function vb_esa_update_email( $post_id ) {
//verify post is not... | [
{
"answer_id": 177924,
"author": "thomascharbit",
"author_id": 35003,
"author_profile": "https://wordpress.stackexchange.com/users/35003",
"pm_score": 1,
"selected": false,
"text": "<p>You were on the right track when you built your WP_User_Query, but you are not using the result of this... | 2015/02/12 | [
"https://wordpress.stackexchange.com/questions/177919",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67445/"
] | I'm just starting out with making plugins and I'm trying to make a simple one that will mail a notification to subscribers whenever I publish a new post.
My code so far:
```
add_action( 'publish_post', 'vb_esa_update_email' );
function vb_esa_update_email( $post_id ) {
//verify post is not a revision
if (... | You were on the right track when you built your WP\_User\_Query, but you are not using the result of this query. See this:
```
//verify post is not a revision
if ( !wp_is_post_revision( $post_id ) ) {
//gets subscirbers to send email to
// WP_User_Query arguments
$args = array (
... |
177,937 | <p>I've had a blog on Azure for quite a while, and despite optimisation attempts, it's still pretty slow. The initial TTFB seems to be a significant time sink.</p>
<p><img src="https://i.stack.imgur.com/7GISa.png" alt="Time check"></p>
<h2>Azure setup</h2>
<p>It's quite a small blog and relatively low traffic so sit... | [
{
"answer_id": 177933,
"author": "mor7ifer",
"author_id": 11740,
"author_profile": "https://wordpress.stackexchange.com/users/11740",
"pm_score": 1,
"selected": false,
"text": "<p>What you likely need is the function <a href=\"http://codex.wordpress.org/Function_Reference/wp_insert_post\... | 2015/02/12 | [
"https://wordpress.stackexchange.com/questions/177937",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44562/"
] | I've had a blog on Azure for quite a while, and despite optimisation attempts, it's still pretty slow. The initial TTFB seems to be a significant time sink.

Azure setup
-----------
It's quite a small blog and relatively low traffic so sits on an Azure s1 instance wi... | What you likely need is the function [`wp_insert_post()`](http://codex.wordpress.org/Function_Reference/wp_insert_post). In your backend (not the WordPress backend, just so we're clear), you'll need to do a minimal load of WordPress to allow [`wp_insert_post()`](http://codex.wordpress.org/Function_Reference/wp_insert_p... |
177,941 | <p>I have a very simple jQuery function that is supposed to toggle a div's visibility:</p>
<pre><code>jQuery( ".signUp" ).click(function() {
$('.signUpForm').toggle();
});
</code></pre>
<p>The HTML is a simple signup form (hidden fields left out for brevity):</p>
<pre><code><p><a class="signUp" href="#"... | [
{
"answer_id": 178093,
"author": "Rachel Baker",
"author_id": 8054,
"author_profile": "https://wordpress.stackexchange.com/users/8054",
"pm_score": 3,
"selected": true,
"text": "<p>You need to wrap your jQuery click event in a DOM ready function.</p>\n\n<pre><code>(function($) {\n $('... | 2015/02/12 | [
"https://wordpress.stackexchange.com/questions/177941",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67455/"
] | I have a very simple jQuery function that is supposed to toggle a div's visibility:
```
jQuery( ".signUp" ).click(function() {
$('.signUpForm').toggle();
});
```
The HTML is a simple signup form (hidden fields left out for brevity):
```
<p><a class="signUp" href="#">Sign Up!</a></p>
<div class="signUpForm">
... | You need to wrap your jQuery click event in a DOM ready function.
```
(function($) {
$('.signUp').click(function() {
$('.signUpForm').toggle();
});
})(jQuery);
``` |
177,943 | <p>I have two CPT: Listings and Events. In Events I have custom fields for the start and end dates. What I need is a way to filter out any events that are past the current date.</p>
<p>What I have right now is: </p>
<pre><code>function search_pre_get_posts( $query ) {
if ( is_search() && $query->is_... | [
{
"answer_id": 177958,
"author": "Jen",
"author_id": 13810,
"author_profile": "https://wordpress.stackexchange.com/users/13810",
"pm_score": 2,
"selected": true,
"text": "<p>You could add a second array to check if the 'DTEND' value is not set:</p>\n\n<pre><code> $args = array_merge( ... | 2015/02/12 | [
"https://wordpress.stackexchange.com/questions/177943",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36436/"
] | I have two CPT: Listings and Events. In Events I have custom fields for the start and end dates. What I need is a way to filter out any events that are past the current date.
What I have right now is:
```
function search_pre_get_posts( $query ) {
if ( is_search() && $query->is_main_query() ) {
... | You could add a second array to check if the 'DTEND' value is not set:
```
$args = array_merge(
$wp_query->query_vars,
array(
'meta_query'=> array(
'relation' => 'OR',
array(
'key' => 'DTEND',
'compare' => '>='... |
177,947 | <p>I'm developing four websites which are separate, besides the Events (custom post type). Three of the websites are WP, and I've got them in a Network. I would like Events to show up in all three Admin interfaces with the same data. All being able to create and edit. Is it possible? It's all the same DB..</p>
| [
{
"answer_id": 177958,
"author": "Jen",
"author_id": 13810,
"author_profile": "https://wordpress.stackexchange.com/users/13810",
"pm_score": 2,
"selected": true,
"text": "<p>You could add a second array to check if the 'DTEND' value is not set:</p>\n\n<pre><code> $args = array_merge( ... | 2015/02/12 | [
"https://wordpress.stackexchange.com/questions/177947",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67457/"
] | I'm developing four websites which are separate, besides the Events (custom post type). Three of the websites are WP, and I've got them in a Network. I would like Events to show up in all three Admin interfaces with the same data. All being able to create and edit. Is it possible? It's all the same DB.. | You could add a second array to check if the 'DTEND' value is not set:
```
$args = array_merge(
$wp_query->query_vars,
array(
'meta_query'=> array(
'relation' => 'OR',
array(
'key' => 'DTEND',
'compare' => '>='... |
177,954 | <p>Unable to login because <code>wp-login.php</code> redirects to <strong>homepage</strong>. </p>
<p>I tried deactivating all plugins but nothing worked. </p>
<p>I didn't install any plugins or make any changes recently.</p>
| [
{
"answer_id": 177969,
"author": "Ferrmolina",
"author_id": 67194,
"author_profile": "https://wordpress.stackexchange.com/users/67194",
"pm_score": 1,
"selected": true,
"text": "<p>Update your DOMAIN site.</p>\n\n<p>Put this in your <code>wp-config.php</code> file</p>\n\n<pre><code>defin... | 2015/02/12 | [
"https://wordpress.stackexchange.com/questions/177954",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | Unable to login because `wp-login.php` redirects to **homepage**.
I tried deactivating all plugins but nothing worked.
I didn't install any plugins or make any changes recently. | Update your DOMAIN site.
Put this in your `wp-config.php` file
```
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
```
Probably thats fix your problem.
Wherever, you can revert back to the Default Theme, renaming the folder of your current theme in `/wp-content/themes/` directory.... |
177,998 | <p>I want to add small jQuery script in my WordPress how to do that?</p>
<p>Here's the JQuery script that I want to add:</p>
<pre><code> ( function( window ) {
'use strict';
function classReg( className ) {
return new RegExp("(^|\\s+)" + className + "(\\s+|$)");
}
var hasClass, addClass, removeClass;
... | [
{
"answer_id": 178000,
"author": "Vincent Wong",
"author_id": 66041,
"author_profile": "https://wordpress.stackexchange.com/users/66041",
"pm_score": -1,
"selected": false,
"text": "<p>You can add them into functions.php file, code below:</p>\n\n<pre><code> //load js\n\n function l... | 2015/02/13 | [
"https://wordpress.stackexchange.com/questions/177998",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62417/"
] | I want to add small jQuery script in my WordPress how to do that?
Here's the JQuery script that I want to add:
```
( function( window ) {
'use strict';
function classReg( className ) {
return new RegExp("(^|\\s+)" + className + "(\\s+|$)");
}
var hasClass, addClass, removeClass;
if ( 'classList' i... | If you are going to add a inline script that depends on jQuery, the best and correct way is to use `wp_enqeue_scripts` action hook, or `wp_footer`, depends on the situation, combined with `wp_script_is()` function:
```
add_action( 'wp_footer', 'cyb_print_inline_script' );
function cyb_print_inline_script() {
//Check... |
178,007 | <p>I'm currently deciding whether or not to use WordPress or write my own code for a future website but I need to know one thing before I can make my final decision.</p>
<p>Is it possible, with WordPress, to insert PHP scripts into a single page. About 40% of my pages will have their own PHP script behind it and I nee... | [
{
"answer_id": 178021,
"author": "efreeman",
"author_id": 59490,
"author_profile": "https://wordpress.stackexchange.com/users/59490",
"pm_score": 0,
"selected": false,
"text": "<p>Every page can use it's own individual template if needed, have a look at the wordpress template heirarchy i... | 2015/02/13 | [
"https://wordpress.stackexchange.com/questions/178007",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59902/"
] | I'm currently deciding whether or not to use WordPress or write my own code for a future website but I need to know one thing before I can make my final decision.
Is it possible, with WordPress, to insert PHP scripts into a single page. About 40% of my pages will have their own PHP script behind it and I need to know ... | Rather than insert PHP scripts into each page what you could do is execute PHP scripts using action [`hooks`](http://codex.wordpress.org/Plugin_API/Hooks) with conditional tags or modify the default output of an existing function using a filter hook with [`conditional tag`](http://codex.wordpress.org/Conditional_Tags) ... |
178,020 | <p>I am trying to add static menu item to Wordpress Menu.I am using filter 'wp_nav_menu_items' for this in functions.php. It works but it doesn't put it under menu container tag.</p>
<pre><code>function add_nav_menu_items( $items , $args ) { ?>
<ul>
<li><a href="#">PRODUCTS</a>
... | [
{
"answer_id": 178021,
"author": "efreeman",
"author_id": 59490,
"author_profile": "https://wordpress.stackexchange.com/users/59490",
"pm_score": 0,
"selected": false,
"text": "<p>Every page can use it's own individual template if needed, have a look at the wordpress template heirarchy i... | 2015/02/13 | [
"https://wordpress.stackexchange.com/questions/178020",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67493/"
] | I am trying to add static menu item to Wordpress Menu.I am using filter 'wp\_nav\_menu\_items' for this in functions.php. It works but it doesn't put it under menu container tag.
```
function add_nav_menu_items( $items , $args ) { ?>
<ul>
<li><a href="#">PRODUCTS</a>
<ul>
<li><a... | Rather than insert PHP scripts into each page what you could do is execute PHP scripts using action [`hooks`](http://codex.wordpress.org/Plugin_API/Hooks) with conditional tags or modify the default output of an existing function using a filter hook with [`conditional tag`](http://codex.wordpress.org/Conditional_Tags) ... |
178,126 | <p>I have 2 dropdown lists, when a user select value in the first list, there is an ajax call to a function using <code>WP_query</code> which send results to populate the second dropdown.</p>
<p>My <code>WP_query</code> is not returning any result. I'm new to <code>WP_query</code> so I should have made a mistake somew... | [
{
"answer_id": 178131,
"author": "Bruno Rodrigues",
"author_id": 42886,
"author_profile": "https://wordpress.stackexchange.com/users/42886",
"pm_score": 1,
"selected": true,
"text": "<p>Try using this:</p>\n\n<pre><code>$args = array(\n 'post_type' => YOUR_POST_TYPE,\n 'meta_que... | 2015/02/14 | [
"https://wordpress.stackexchange.com/questions/178126",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67069/"
] | I have 2 dropdown lists, when a user select value in the first list, there is an ajax call to a function using `WP_query` which send results to populate the second dropdown.
My `WP_query` is not returning any result. I'm new to `WP_query` so I should have made a mistake somewhere.
The query should return the posts ha... | Try using this:
```
$args = array(
'post_type' => YOUR_POST_TYPE,
'meta_query' => array(
array(
'key' => '_wpcf_belongs_marque-type_id',
'value' => $parent_id
)
)
);
```
In your loop set an `else` statement just to sure that you query isn't returning zero res... |
178,132 | <p>I do not want to have a function loaded by my theme on a page template. </p>
<ol>
<li>Is this the correct syntax?</li>
<li>What does 99 mean here? <code>add_filter('the_content', 'oswc_formatter', 99);</code></li>
<li>Could I apply the condition on the <code>add_filter</code> instead of what I did? </li>
</ol>
<... | [
{
"answer_id": 178131,
"author": "Bruno Rodrigues",
"author_id": 42886,
"author_profile": "https://wordpress.stackexchange.com/users/42886",
"pm_score": 1,
"selected": true,
"text": "<p>Try using this:</p>\n\n<pre><code>$args = array(\n 'post_type' => YOUR_POST_TYPE,\n 'meta_que... | 2015/02/14 | [
"https://wordpress.stackexchange.com/questions/178132",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40727/"
] | I do not want to have a function loaded by my theme on a page template.
1. Is this the correct syntax?
2. What does 99 mean here? `add_filter('the_content', 'oswc_formatter', 99);`
3. Could I apply the condition on the `add_filter` instead of what I did?
This is my code:
```
function oswc_formatter($content) {
if( ... | Try using this:
```
$args = array(
'post_type' => YOUR_POST_TYPE,
'meta_query' => array(
array(
'key' => '_wpcf_belongs_marque-type_id',
'value' => $parent_id
)
)
);
```
In your loop set an `else` statement just to sure that you query isn't returning zero res... |
178,135 | <p>I have a WordPress site which has the built-in login form with the url <code>http://domain.com/wp-login.php</code> and register page <code>http://domain.com/wp-login.php?action=register</code></p>
<p>I want to display these forms on a page I created from the backend.</p>
<p>login </p>
<pre><code>http://domain.com... | [
{
"answer_id": 178136,
"author": "Bruno Rodrigues",
"author_id": 42886,
"author_profile": "https://wordpress.stackexchange.com/users/42886",
"pm_score": 1,
"selected": false,
"text": "<p>You could try to add this to your <code>.htaccess</code> file:</p>\n\n<pre><code>Redirect 301 http://... | 2015/02/14 | [
"https://wordpress.stackexchange.com/questions/178135",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67551/"
] | I have a WordPress site which has the built-in login form with the url `http://domain.com/wp-login.php` and register page `http://domain.com/wp-login.php?action=register`
I want to display these forms on a page I created from the backend.
login
```
http://domain.com/profile/login
```
register
```
http://domain.... | You could try to add this to your `.htaccess` file:
```
Redirect 301 http://domain.com/wp-login.php http://domain.com/profile/login
Redirect 301 http://domain.com/wp-login.php?action=register http://domain.com/profile/register
```
Hope it helps. |
178,139 | <p>The posts in the website I'm currently working on have multiple hierarchical categories applied to each of them. For instance:</p>
<pre><code>Source
- Books
-- Moby Dick
-- Sherlock Holmes
</code></pre>
<p>The permalinks are set as <code>/%category%/%postname%/</code>. However, the URL of a post does not include a... | [
{
"answer_id": 178169,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 3,
"selected": true,
"text": "<p>The permastruct <code>/%category%/%postname%/</code> will include the categories and subcategories in the URL ... | 2015/02/14 | [
"https://wordpress.stackexchange.com/questions/178139",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63683/"
] | The posts in the website I'm currently working on have multiple hierarchical categories applied to each of them. For instance:
```
Source
- Books
-- Moby Dick
-- Sherlock Holmes
```
The permalinks are set as `/%category%/%postname%/`. However, the URL of a post does not include all subcategories - all I get is `site... | The permastruct `/%category%/%postname%/` will include the categories and subcategories in the URL **from top to first assigned child**. So, if you want the URL be `site.com/source/books/moby-dick/*postname*`, you have to assign the post only to "Moby Dick". Assigning the post only to "Moby Dick" category will still sh... |
178,144 | <p><code>shortcode_unautop()</code> in <code>/wp-includes/formatting.php</code> is supposed to find shortcodes in a block of text and remove wrapping paragraph tags from them.</p>
<p>I've been having issues with paragraph tags making it through this process. </p>
<p>Here's the output from <code>var_dump($pee)</code>... | [
{
"answer_id": 178161,
"author": "mathieuhays",
"author_id": 67529,
"author_profile": "https://wordpress.stackexchange.com/users/67529",
"pm_score": 1,
"selected": false,
"text": "<p>I've been reading the WordPress documentation about this function and the behaviour you are having there,... | 2015/02/14 | [
"https://wordpress.stackexchange.com/questions/178144",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34363/"
] | `shortcode_unautop()` in `/wp-includes/formatting.php` is supposed to find shortcodes in a block of text and remove wrapping paragraph tags from them.
I've been having issues with paragraph tags making it through this process.
Here's the output from `var_dump($pee)`, which I placed at the very beginning of the funct... | It seems the function *is* broken. The issue is in trac: <https://core.trac.wordpress.org/ticket/14050>
I am using this to solve the problem temporarily: <https://core.trac.wordpress.org/attachment/ticket/14050/plugin.php> . This code still fails some of the tests used, but it completely resolves the issue I described... |
178,145 | <p>In the year archive page in the title tag i get</p>
<pre><code>Notice: Undefined index: 00 in wp-includes\locale.php on line 271
</code></pre>
<p>In the header.php i use:</p>
<pre><code><title><?php wp_title('|', true, 'right'); ?></title>
</code></pre>
<p>I even tried to use in functions.php <... | [
{
"answer_id": 178161,
"author": "mathieuhays",
"author_id": 67529,
"author_profile": "https://wordpress.stackexchange.com/users/67529",
"pm_score": 1,
"selected": false,
"text": "<p>I've been reading the WordPress documentation about this function and the behaviour you are having there,... | 2015/02/14 | [
"https://wordpress.stackexchange.com/questions/178145",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47813/"
] | In the year archive page in the title tag i get
```
Notice: Undefined index: 00 in wp-includes\locale.php on line 271
```
In the header.php i use:
```
<title><?php wp_title('|', true, 'right'); ?></title>
```
I even tried to use in functions.php
```
add_theme_support( 'title-tag' );
```
My question: is WordPr... | It seems the function *is* broken. The issue is in trac: <https://core.trac.wordpress.org/ticket/14050>
I am using this to solve the problem temporarily: <https://core.trac.wordpress.org/attachment/ticket/14050/plugin.php> . This code still fails some of the tests used, but it completely resolves the issue I described... |
178,146 | <p>If I have developed a separate HTML page that I wish to include inside my Wordpress site what is the best way of including it?
In this case it requires a javascript library or stylesheet that is not by default in my Wordpress theme that would need to be inserted in the tag.</p>
<p>I am aware of the following solut... | [
{
"answer_id": 178150,
"author": "stanton119",
"author_id": 67552,
"author_profile": "https://wordpress.stackexchange.com/users/67552",
"pm_score": 3,
"selected": true,
"text": "<p>I found the best solution was to add a custom field, <code>head</code>, and then build a short plugin to ad... | 2015/02/14 | [
"https://wordpress.stackexchange.com/questions/178146",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67552/"
] | If I have developed a separate HTML page that I wish to include inside my Wordpress site what is the best way of including it?
In this case it requires a javascript library or stylesheet that is not by default in my Wordpress theme that would need to be inserted in the tag.
I am aware of the following solutions:
iFra... | I found the best solution was to add a custom field, `head`, and then build a short plugin to add the contents to the head tag:
```
add_action('wp_head', 'add_HTML_head');
function add_HTML_head(){
global $post;
if(!empty($post)){
// get custom field for 'head'
$headHTML = get_post_meta($post->... |
178,148 | <p>If the custom post type is known (e.g., 'reference') then the add_action is </p>
<pre><code>add_action( 'publish_reference' , 'run_new_post_code' );
</code></pre>
<p>Great. But what is the proper code for an unknown custom post type? I tried to add a text box so the custom_post_type could be added by the end-user.... | [
{
"answer_id": 178150,
"author": "stanton119",
"author_id": 67552,
"author_profile": "https://wordpress.stackexchange.com/users/67552",
"pm_score": 3,
"selected": true,
"text": "<p>I found the best solution was to add a custom field, <code>head</code>, and then build a short plugin to ad... | 2015/02/14 | [
"https://wordpress.stackexchange.com/questions/178148",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47326/"
] | If the custom post type is known (e.g., 'reference') then the add\_action is
```
add_action( 'publish_reference' , 'run_new_post_code' );
```
Great. But what is the proper code for an unknown custom post type? I tried to add a text box so the custom\_post\_type could be added by the end-user. This is then called in... | I found the best solution was to add a custom field, `head`, and then build a short plugin to add the contents to the head tag:
```
add_action('wp_head', 'add_HTML_head');
function add_HTML_head(){
global $post;
if(!empty($post)){
// get custom field for 'head'
$headHTML = get_post_meta($post->... |
178,155 | <p>Normally, in WordPress, the page title appears in the content area. I'd like to have the page title appear in the header area. It looks like to do that, I'd have to remove it from its current location in the content-page.php and place it in header.php. But content-page.php is called from page.php, which calls the co... | [
{
"answer_id": 178158,
"author": "mathieuhays",
"author_id": 67529,
"author_profile": "https://wordpress.stackexchange.com/users/67529",
"pm_score": 4,
"selected": true,
"text": "<p>If you only need the title you can request it outside the loop easily.</p>\n\n<p><em>Try and call <code>th... | 2015/02/14 | [
"https://wordpress.stackexchange.com/questions/178155",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67531/"
] | Normally, in WordPress, the page title appears in the content area. I'd like to have the page title appear in the header area. It looks like to do that, I'd have to remove it from its current location in the content-page.php and place it in header.php. But content-page.php is called from page.php, which calls the conte... | If you only need the title you can request it outside the loop easily.
*Try and call `the_title()` in your header. It should work*
But you have to be aware that if you don't put a condition, each page of your website will display its title in the header section.
EDIT: the function to call is `get_the_title($post->ID... |
178,199 | <p>I'm in the process of setting up WordPress over HTTPS, which is hosted on a Digital Ocean VPS, managed by Serverpilot (though the HTTPS is set up manually, rather than through Serverpilot). The server has a number of WordPress installations, but there is one in particular I wanted to run securely. WordPress in itsel... | [
{
"answer_id": 298591,
"author": "robyoder",
"author_id": 140175,
"author_profile": "https://wordpress.stackexchange.com/users/140175",
"pm_score": 3,
"selected": false,
"text": "<p>The answer to this came in part from <a href=\"/a/179420\">this answer</a>, which linked to <a href=\"http... | 2015/02/15 | [
"https://wordpress.stackexchange.com/questions/178199",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9918/"
] | I'm in the process of setting up WordPress over HTTPS, which is hosted on a Digital Ocean VPS, managed by Serverpilot (though the HTTPS is set up manually, rather than through Serverpilot). The server has a number of WordPress installations, but there is one in particular I wanted to run securely. WordPress in itself i... | The answer to this came in part from [this answer](/a/179420), which linked to [the Codex](https://codex.wordpress.org/Administration_Over_SSL#Using_a_Reverse_Proxy), advising the following snippet to be placed at the top of the wp-config file:
```
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
... |
178,222 | <p>I'm working on looping through some books for a custom post type with advanced custom fields. One of the ACF's is a checkbox, and I'm wanting to only show the values with this one checked. The current loop I'm using is:</p>
<pre><code><?php
$args = array (
'post_type' => 'book',
'posts_per_page' =>... | [
{
"answer_id": 178341,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p>If you go to <a href=\"http://gravatar.com/d6b10d5767d1e29006c11e1a2c590f3c\" rel=\"nofollow\">http://gravatar.com/... | 2015/02/16 | [
"https://wordpress.stackexchange.com/questions/178222",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67589/"
] | I'm working on looping through some books for a custom post type with advanced custom fields. One of the ACF's is a checkbox, and I'm wanting to only show the values with this one checked. The current loop I'm using is:
```
<?php
$args = array (
'post_type' => 'book',
'posts_per_page' => '2'
);
$thequery = n... | If you go to <http://gravatar.com/d6b10d5767d1e29006c11e1a2c590f3c> (omit the /avatar/ from path) you get <http://gravatar.com/clojita> which seems to be your gravatar account, correct?
MD5 collision is unlikely (but maybe it's time to buy a lottery ticket :)
Look at source fetches interesting detail — the comment in... |
178,237 | <p>I have a multisite WordPress project with a main site using <strong>Theme A</strong> and all 'sub'-sites using <strong>Theme B</strong>.</p>
<p>Both <strong>Theme A</strong> and <strong>Theme B</strong> are Child Themes.</p>
<p>I want to import the header file from Theme A into Theme B, so I can show that header b... | [
{
"answer_id": 178239,
"author": "David Gard",
"author_id": 10097,
"author_profile": "https://wordpress.stackexchange.com/users/10097",
"pm_score": 0,
"selected": false,
"text": "<p>You could make Theme B a <a href=\"http://codex.wordpress.org/Child_Themes\" rel=\"nofollow\"><strong>Chil... | 2015/02/16 | [
"https://wordpress.stackexchange.com/questions/178237",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67338/"
] | I have a multisite WordPress project with a main site using **Theme A** and all 'sub'-sites using **Theme B**.
Both **Theme A** and **Theme B** are Child Themes.
I want to import the header file from Theme A into Theme B, so I can show that header before Theme B's header - how would I implement this header properly?
... | As you have now stated that both Theme A and Theme B are already Child Themes, perhaps you could try adding this to your **funcions.php** file in Theme B -
```
add_action('wp_enqueue_scripts', 'enqueue_front_scripts');
function enqueue_front_scripts(){
/** Switch to the parent blog */
switch_to_blog(1); // Y... |
178,243 | <p>I am looking for a way to quickly and repeatedly set up <strong>testing / debugging environment</strong> for our plugin, most probably using <strong>Vagrant</strong>. Projects like <a href="https://github.com/Varying-Vagrant-Vagrants/VVV">VVV</a> focus on a single-environment setup (or, a couple of environments like... | [
{
"answer_id": 183846,
"author": "GastroGeek",
"author_id": 70445,
"author_profile": "https://wordpress.stackexchange.com/users/70445",
"pm_score": 0,
"selected": false,
"text": "<p>Have you looked at this?</p>\n\n<p><a href=\"https://puphpet.com\" rel=\"nofollow\">puphpet</a></p>\n\n<p>... | 2015/02/16 | [
"https://wordpress.stackexchange.com/questions/178243",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12248/"
] | I am looking for a way to quickly and repeatedly set up **testing / debugging environment** for our plugin, most probably using **Vagrant**. Projects like [VVV](https://github.com/Varying-Vagrant-Vagrants/VVV) focus on a single-environment setup (or, a couple of environments like stable / trunk) while what I'm looking ... | On the WordPress side of things, [Basic WordPress Vagrant Environment](https://github.com/ideasonpurpose/basic-wordpress-vagrant) is ready to work with any WordPress version (with a little help). You would still need to find a way to configure the PHP but there is a hint in [`https://github.com/ideasonpurpose/basic-wor... |
178,256 | <p>I am displaying results from a custom post type ("works") and want to optionally filter by a custom taxonomy ("genre") if that is set (i.e. if the loop is on the custom taxonomy archive template).</p>
<p>I am using a wp_query with arguments, but it is not filtering by the custom taxonomy slug- it's returning all re... | [
{
"answer_id": 178266,
"author": "cristian.raiber",
"author_id": 52524,
"author_profile": "https://wordpress.stackexchange.com/users/52524",
"pm_score": 0,
"selected": false,
"text": "<pre><code>$args = array( \n 'post_type' => 'works', \n 'posts_per_page' => 40, \n 'meta... | 2015/02/16 | [
"https://wordpress.stackexchange.com/questions/178256",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5864/"
] | I am displaying results from a custom post type ("works") and want to optionally filter by a custom taxonomy ("genre") if that is set (i.e. if the loop is on the custom taxonomy archive template).
I am using a wp\_query with arguments, but it is not filtering by the custom taxonomy slug- it's returning all results.
F... | As I stated in comments, use [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) to alter the main query. Never replace the main query with a custom one. Again, from comments
>
> Just for starters, on each page load you are running the same query twice, it is slow, double the amoun... |
178,287 | <p>In my <code>functions.php</code> I would like to enqueue a CSS file conditional on whether a custom field exists on the page or custom post type. How should I go about this?</p>
<pre><code> function flatsome_scripts()
{
wp_enqueue_style( 'flatsome-icons', get_template_directory_uri() .'/flatme/css/fonts.c... | [
{
"answer_id": 178266,
"author": "cristian.raiber",
"author_id": 52524,
"author_profile": "https://wordpress.stackexchange.com/users/52524",
"pm_score": 0,
"selected": false,
"text": "<pre><code>$args = array( \n 'post_type' => 'works', \n 'posts_per_page' => 40, \n 'meta... | 2015/02/16 | [
"https://wordpress.stackexchange.com/questions/178287",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40727/"
] | In my `functions.php` I would like to enqueue a CSS file conditional on whether a custom field exists on the page or custom post type. How should I go about this?
```
function flatsome_scripts()
{
wp_enqueue_style( 'flatsome-icons', get_template_directory_uri() .'/flatme/css/fonts.css', array(), '2.1', 'all... | As I stated in comments, use [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) to alter the main query. Never replace the main query with a custom one. Again, from comments
>
> Just for starters, on each page load you are running the same query twice, it is slow, double the amoun... |
178,294 | <p>A few words in the WP Job Manager weren't translated yet. I edited most of them in de po file now but for the sentence "posted 5 hours ago" I can't find where to translate the "Hours" </p>
<p>It's declared as <code>%s</code> in the po file, Cant find the word hour in any of the plugin's files... </p>
<p>so where t... | [
{
"answer_id": 178296,
"author": "cristian.raiber",
"author_id": 52524,
"author_profile": "https://wordpress.stackexchange.com/users/52524",
"pm_score": -1,
"selected": true,
"text": "<p>Since your problem resolves around the fact that the WP theme developers used a function that doesn't... | 2015/02/16 | [
"https://wordpress.stackexchange.com/questions/178294",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67623/"
] | A few words in the WP Job Manager weren't translated yet. I edited most of them in de po file now but for the sentence "posted 5 hours ago" I can't find where to translate the "Hours"
It's declared as `%s` in the po file, Cant find the word hour in any of the plugin's files...
so where to change the "hours" term of... | Since your problem resolves around the fact that the WP theme developers used a function that doesn't have any hooks so we could easily alter the output, you're going to have to copy & paste the following code in your functions.php file
```
function human_time_diff( $from, $to = '' ) {
if ( empty( $to ) ) {
... |
178,297 | <p>My theme uses Magnific Popup as follows in <code>theme.js</code></p>
<pre><code> /* add lightbox for blog galleries */
$(".gallery a[href$='.jpg'],.gallery a[href$='.jpeg'],.featured-item a[href$='.jpeg'],.featured-item a[href$='.gif'],.featured-item a[href$='.jpg'], .page-featured-item .slider a[href$='.jpg'], ... | [
{
"answer_id": 178296,
"author": "cristian.raiber",
"author_id": 52524,
"author_profile": "https://wordpress.stackexchange.com/users/52524",
"pm_score": -1,
"selected": true,
"text": "<p>Since your problem resolves around the fact that the WP theme developers used a function that doesn't... | 2015/02/16 | [
"https://wordpress.stackexchange.com/questions/178297",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40727/"
] | My theme uses Magnific Popup as follows in `theme.js`
```
/* add lightbox for blog galleries */
$(".gallery a[href$='.jpg'],.gallery a[href$='.jpeg'],.featured-item a[href$='.jpeg'],.featured-item a[href$='.gif'],.featured-item a[href$='.jpg'], .page-featured-item .slider a[href$='.jpg'], .page-featured-item a[hre... | Since your problem resolves around the fact that the WP theme developers used a function that doesn't have any hooks so we could easily alter the output, you're going to have to copy & paste the following code in your functions.php file
```
function human_time_diff( $from, $to = '' ) {
if ( empty( $to ) ) {
... |
178,302 | <p>I need to find posts with a meta key that starts with the current year + the current month (i.e. 201502), but the actual value could also contain any day within that month (i.e. 20150214). </p>
<p>The really tricky part is that I'm trying to do this with ACF's Reapter and Date Picker fields. I've got it working to ... | [
{
"answer_id": 178304,
"author": "David Gard",
"author_id": 10097,
"author_profile": "https://wordpress.stackexchange.com/users/10097",
"pm_score": 0,
"selected": false,
"text": "<p>I believe all you need to do here is remove the day from your <code>$this_month</code> parameter and use t... | 2015/02/16 | [
"https://wordpress.stackexchange.com/questions/178302",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24566/"
] | I need to find posts with a meta key that starts with the current year + the current month (i.e. 201502), but the actual value could also contain any day within that month (i.e. 20150214).
The really tricky part is that I'm trying to do this with ACF's Reapter and Date Picker fields. I've got it working to where it c... | I figured it out:
```
$the_query = new WP_Query(array(
"numberposts" => -1,
"post_type" => "plays_events",
"meta_query" => array(
array(
"key" => "show_times_%_date",
"value" => $this_month . "[0-9]{2}",
"compare" => "REGEXP"
)
),
));
``` |
178,309 | <p>I've created a custom post type <code>portfolio</code> and a <code>taxonomy</code> of course. </p>
<pre><code>function taxonomies_portfolio() {
$labels = array(
'name' => _x( 'Portfolio categories', 'taxonomy general name' ),
'singular_name' => _x( 'Portfolio categories', ... | [
{
"answer_id": 178311,
"author": "Manny Fleurmond",
"author_id": 2234,
"author_profile": "https://wordpress.stackexchange.com/users/2234",
"pm_score": 4,
"selected": true,
"text": "<p>According to the Wordpress Codex page on <a href=\"http://codex.wordpress.org/Template_Hierarchy#Custom_... | 2015/02/16 | [
"https://wordpress.stackexchange.com/questions/178309",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58496/"
] | I've created a custom post type `portfolio` and a `taxonomy` of course.
```
function taxonomies_portfolio() {
$labels = array(
'name' => _x( 'Portfolio categories', 'taxonomy general name' ),
'singular_name' => _x( 'Portfolio categories', 'taxonomy singular name' ),
'searc... | According to the Wordpress Codex page on [Template Hierarchy](http://codex.wordpress.org/Template_Hierarchy#Custom_Taxonomies_display), you create a template file with the name of `taxonomy-portfolio_category.php`. WordPress will use that to display the archive for that taxonomy. You can also use `taxonomy-portfolio_ca... |
178,321 | <p>I'm trying to get the meta info by key <code>rw_related_link</code> for each post but my code is wrong since instead get the ones related to the current post I got the same in all post and that's wrong. This is what I have at <code>single.php</code>:</p>
<pre><code>if (have_posts()) {
while (have_posts()) {
... | [
{
"answer_id": 178329,
"author": "Bruno Rodrigues",
"author_id": 42886,
"author_profile": "https://wordpress.stackexchange.com/users/42886",
"pm_score": 3,
"selected": true,
"text": "<p>The way you did in your code you are querying posts with the key <code>rw_related_link</code>.</p>\n\n... | 2015/02/16 | [
"https://wordpress.stackexchange.com/questions/178321",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16412/"
] | I'm trying to get the meta info by key `rw_related_link` for each post but my code is wrong since instead get the ones related to the current post I got the same in all post and that's wrong. This is what I have at `single.php`:
```
if (have_posts()) {
while (have_posts()) {
the_post();
$no... | The way you did in your code you are querying posts with the key `rw_related_link`.
If I understood you right, you must use get\_post\_meta inside the loop.
```
<?php while ($normal_query->have_posts()) {
$normal_query->the_post();
$related_link = get_post_meta(get_the_ID(), 'rw_related_link', tr... |
178,327 | <p>I am trying to create a Facebook JS-SDK based auto login feature. When user is "Connected" passing FbID and aother user data to an ajax function which creates the session cookie. Cookie is created (I can see <code>"wordpress_logged_in_.... cookie"</code> in the browser inspector) but when I reload the page the user ... | [
{
"answer_id": 243845,
"author": "AddWeb Solution Pvt Ltd",
"author_id": 73643,
"author_profile": "https://wordpress.stackexchange.com/users/73643",
"pm_score": 2,
"selected": false,
"text": "<p>I add one function <a href=\"https://codex.wordpress.org/Function_Reference/wp_set_current_us... | 2015/02/16 | [
"https://wordpress.stackexchange.com/questions/178327",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9909/"
] | I am trying to create a Facebook JS-SDK based auto login feature. When user is "Connected" passing FbID and aother user data to an ajax function which creates the session cookie. Cookie is created (I can see `"wordpress_logged_in_.... cookie"` in the browser inspector) but when I reload the page the user is still logge... | I add one function [wp\_set\_current\_user](https://codex.wordpress.org/Function_Reference/wp_set_current_user) for setting up current user.
```
add_action( 'wp_ajax_facebook_login', 'facebook_ajax_login_or_register' );
add_action( 'wp_ajax_nopriv_facebook_login', 'facebook_ajax_login_or_register' );
function faceboo... |
178,331 | <p>Is there a native function to display the correct responsive image size for post thumbnails or gallery images depending on the screen resolution?</p>
<p>Normally I'm using:</p>
<p>1.Custom image sizes:</p>
<pre><code>function customImageSetup () {
add_theme_support( 'post-thumbnails' );
add_image_size('grid_1... | [
{
"answer_id": 178333,
"author": "cristian.raiber",
"author_id": 52524,
"author_profile": "https://wordpress.stackexchange.com/users/52524",
"pm_score": 1,
"selected": false,
"text": "<p>No, there isn't such a thing at the moment. However, there is a solution you could try if you're real... | 2015/02/16 | [
"https://wordpress.stackexchange.com/questions/178331",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58496/"
] | Is there a native function to display the correct responsive image size for post thumbnails or gallery images depending on the screen resolution?
Normally I'm using:
1.Custom image sizes:
```
function customImageSetup () {
add_theme_support( 'post-thumbnails' );
add_image_size('grid_1 mini square', 60, 60, TRUE)... | To add to the answer from @cristian.raiber, there is no function in Wordpress or php to detect screen sizes, and there will in all probabilty never be such functionality. Php runs server side, which runs before clients side which is browser side. As for php, and for that matter Wordpress, I cannot see any future implem... |
178,356 | <p>So, for the Plupload, I know there is a documentation to how to resize the image on the client side before uploading : <a href="http://www.plupload.com/docs/Image-Resizing-on-Client-Side" rel="nofollow">http://www.plupload.com/docs/Image-Resizing-on-Client-Side</a></p>
<p>However, I am not sure how to do it for Wor... | [
{
"answer_id": 178473,
"author": "Leo Caseiro",
"author_id": 52791,
"author_profile": "https://wordpress.stackexchange.com/users/52791",
"pm_score": 2,
"selected": true,
"text": "<p>I've done a Plupload using the Front End. The WordPress Plupload is very customised, so I've implemented f... | 2015/02/16 | [
"https://wordpress.stackexchange.com/questions/178356",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67604/"
] | So, for the Plupload, I know there is a documentation to how to resize the image on the client side before uploading : <http://www.plupload.com/docs/Image-Resizing-on-Client-Side>
However, I am not sure how to do it for Wordpress.
Could you guys give me a guidance to how to do this?
Thank you so much!
Regards | I've done a Plupload using the Front End. The WordPress Plupload is very customised, so I've implemented from the scratch as a Plugin. I'll show an example using *functions.php*
Download the Plupload from <http://www.plupload.com/download/> and put in your theme inside a js/thirdparty/plupload/{all\_files}
Code to us... |
178,370 | <p>I am having problems enqueuing javascript. When I use the script tag in the head section of my site, everything works just fine. If I take the scripts out and use enqueue, the site breaks but I don't get any errors in firebug. Viewing the source code, the entire page looks as if it is there but obviously some of the... | [
{
"answer_id": 178372,
"author": "Privateer",
"author_id": 66020,
"author_profile": "https://wordpress.stackexchange.com/users/66020",
"pm_score": 2,
"selected": false,
"text": "<p>What you might do is check the status of the scripts you are trying to enqueue after doing so.</p>\n\n<p>Al... | 2015/02/17 | [
"https://wordpress.stackexchange.com/questions/178370",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14761/"
] | I am having problems enqueuing javascript. When I use the script tag in the head section of my site, everything works just fine. If I take the scripts out and use enqueue, the site breaks but I don't get any errors in firebug. Viewing the source code, the entire page looks as if it is there but obviously some of the js... | What you might do is check the status of the scripts you are trying to enqueue after doing so.
Also, be sure to enqueue things inside of an action.
e.g.
```
function do_my_enqueue_scripts() {
wp_register_script('isotope', get_template_directory_uri() . '/js/jquery.isotope.min.js',array('jquery'),'',true);
wp_... |
178,376 | <p>In order to speedup my site load and prevent scripts from render the page I'm trying to move all the <strong>possible</strong> scripts (meaning JS files) from <code>head</code> to <code>footer</code>. After read and do some research I made this code:</p>
<pre><code>function footer_enqueue_scripts() {
remove_act... | [
{
"answer_id": 178379,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": true,
"text": "<p>IMHO, I still think that loading scripts and styles directly in the header is bad practice as it is alwa... | 2015/02/17 | [
"https://wordpress.stackexchange.com/questions/178376",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16412/"
] | In order to speedup my site load and prevent scripts from render the page I'm trying to move all the **possible** scripts (meaning JS files) from `head` to `footer`. After read and do some research I made this code:
```
function footer_enqueue_scripts() {
remove_action('wp_head', 'wp_print_scripts');
remove_ac... | IMHO, I still think that loading scripts and styles directly in the header is bad practice as it is always a problem removing them and loading them coditionally.
The best way to work around this is to create a [child theme] and then copy `header.php` to your child theme. Wordpress will load your child theme's header ... |
178,386 | <p>Bit of a odd question. I want to be able to host example simple websites on my Wordpress Site. These "simple" sites would just consist of client side code.</p>
<p>Is there a way to create a page which just uses these files, possible a plugin I am unaware of?</p>
<p>Thank you.</p>
| [
{
"answer_id": 178394,
"author": "Florian Grell",
"author_id": 66399,
"author_profile": "https://wordpress.stackexchange.com/users/66399",
"pm_score": 0,
"selected": false,
"text": "<p>Create a directory named <em>(for example)</em> <code>example</code> in the root directory of your doma... | 2015/02/17 | [
"https://wordpress.stackexchange.com/questions/178386",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44487/"
] | Bit of a odd question. I want to be able to host example simple websites on my Wordpress Site. These "simple" sites would just consist of client side code.
Is there a way to create a page which just uses these files, possible a plugin I am unaware of?
Thank you. | I've done this in the past by using [custom page templates](https://developer.wordpress.org/themes/template-files-section/page-template-files/).
Basically, there are two ways to create a custom page template.
1. You can create a file in your themes directory and name it `page-vanilla-html.php`.
2. You can create a fi... |
178,405 | <p>I cannot seem to save the value of a checkbox in a plugin I am creating. When I uncheck it and click Save Settings, it reverts to being checked again.
I'm not sure where I have gone wrong. Any help would be most appreciated. </p>
<pre><code>//Global Variable
$options = array();
//Options Page
function iwmp_opt... | [
{
"answer_id": 178506,
"author": "Nikola Ivanov Nikolov",
"author_id": 23604,
"author_profile": "https://wordpress.stackexchange.com/users/23604",
"pm_score": 3,
"selected": true,
"text": "<p>If a checkbox is unchecked, it doesn't get submitted with the form values. So when using checkbo... | 2015/02/17 | [
"https://wordpress.stackexchange.com/questions/178405",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57571/"
] | I cannot seem to save the value of a checkbox in a plugin I am creating. When I uncheck it and click Save Settings, it reverts to being checked again.
I'm not sure where I have gone wrong. Any help would be most appreciated.
```
//Global Variable
$options = array();
//Options Page
function iwmp_options_page() {
... | If a checkbox is unchecked, it doesn't get submitted with the form values. So when using checkboxes, you should have an `else` statement for `isset( $_POST['iwmp_settings_form_submitted'] )` and it basically will be triggered when the checkbox is unchecked. Here's the fixed code.
```
//Global Variable
$options = arra... |
178,416 | <p>I searched in various places and am battling to find the correct place or terms used for the following.</p>
<p>I am only using posts as an example.</p>
<p>When you view all posts in wp-admin you get the title of the post and below it the Edit, Quick Edit, Trash and Preview links. By using the post_row_actions acti... | [
{
"answer_id": 178421,
"author": "mjakic",
"author_id": 67333,
"author_profile": "https://wordpress.stackexchange.com/users/67333",
"pm_score": 4,
"selected": true,
"text": "<p>Use <a href=\"https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/link-template.php#L1193\" rel=\"... | 2015/02/17 | [
"https://wordpress.stackexchange.com/questions/178416",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63672/"
] | I searched in various places and am battling to find the correct place or terms used for the following.
I am only using posts as an example.
When you view all posts in wp-admin you get the title of the post and below it the Edit, Quick Edit, Trash and Preview links. By using the post\_row\_actions action hook I can c... | Use [`get_edit_post_link` filter](https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/link-template.php#L1193).
```
add_filter('get_edit_post_link', 'get_edit_post_link_178416', 99, 3);
function get_edit_post_link_178416($link, $post_id, $context) {
$scr = get_current_screen();
if ($scr->id == '... |
178,433 | <p>I'm searching for science related terms. Here's what I need my query to do. If someone searches 'bio', they should not get results for terms 'biology' but they should for 'bio science'. I need the query to return results for the whole word. Any suggestions are appreciated. Thanks!</p>
<p>Here is my code:</p>
<... | [
{
"answer_id": 178439,
"author": "geomagas",
"author_id": 39275,
"author_profile": "https://wordpress.stackexchange.com/users/39275",
"pm_score": 3,
"selected": true,
"text": "<p>You're gonna need regular expressions to accomplish that.</p>\n\n<p>First of all, you need to change <code>'L... | 2015/02/17 | [
"https://wordpress.stackexchange.com/questions/178433",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37809/"
] | I'm searching for science related terms. Here's what I need my query to do. If someone searches 'bio', they should not get results for terms 'biology' but they should for 'bio science'. I need the query to return results for the whole word. Any suggestions are appreciated. Thanks!
Here is my code:
```
$queryArgs ... | You're gonna need regular expressions to accomplish that.
First of all, you need to change `'LIKE'` to `'RLIKE'` (or `'REGEXP'`).
Second, replace `$keyword` in `'value'` with a regex that involves word boundaries.
Like so:
```
$queryArgs = array(
'post_type' => 'faculty',
'posts_per_page' => -1,
'meta... |
178,437 | <p>I'm trying to make a couple of Page Templates for different Pages that should act as an archive to display posts (a Custom Post Type actually) in a certain date range.</p>
<p>The website it concerns is <a href="http://memstories.com" rel="nofollow">http://memstories.com</a> and the CPT is "Events". I already found ... | [
{
"answer_id": 178441,
"author": "Sean Grant",
"author_id": 67105,
"author_profile": "https://wordpress.stackexchange.com/users/67105",
"pm_score": 1,
"selected": false,
"text": "<p>Well, WP may be suppressing your filter.</p>\n\n<p>Per the WP Codex on posts_where @: <a href=\"http://cod... | 2015/02/17 | [
"https://wordpress.stackexchange.com/questions/178437",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35523/"
] | I'm trying to make a couple of Page Templates for different Pages that should act as an archive to display posts (a Custom Post Type actually) in a certain date range.
The website it concerns is <http://memstories.com> and the CPT is "Events". I already found some mentions of a thread on WP Support (<https://wordpress... | Saving the date in post meta is a slightly more sane approach, the `post_date` column was not designed with your use case in mind. You may get weird results with dates before the Unix epoch (January 1, 1970). Then it's just a simple `meta_query` to load posts between dates, no filter necessary.
```
$start = '1900-01-0... |
178,455 | <p>The <code><title></code> of each page on my site shows correctly with the following code:</p>
<pre><code><title><?php wp_title(''); ?></title>
</code></pre>
<p>But on my home page, which is set to a static page called 'Home', the <code><title></code> attribute is blank. The HTML for '... | [
{
"answer_id": 178457,
"author": "czerspalace",
"author_id": 47406,
"author_profile": "https://wordpress.stackexchange.com/users/47406",
"pm_score": 3,
"selected": true,
"text": "<p>From the <a href=\"http://codex.wordpress.org/Function_Reference/wp_title#Covering_Homepage\" rel=\"nofoll... | 2015/02/17 | [
"https://wordpress.stackexchange.com/questions/178455",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34397/"
] | The `<title>` of each page on my site shows correctly with the following code:
```
<title><?php wp_title(''); ?></title>
```
But on my home page, which is set to a static page called 'Home', the `<title>` attribute is blank. The HTML for 'Home' page looks like this:
```
<title></title>
```
The settings for the 'H... | From the [Codex](http://codex.wordpress.org/Function_Reference/wp_title#Covering_Homepage)
`If you are using a custom homepage with custom loops and stuff or a custom front-page, you will have an empty wp_title. Here goes a neat hack to add the description/tagline at the wp_title place on homepage:`
```
add_filter( '... |
178,466 | <p>I am trying to change the comment author name (or more specifically, the review author in WooCommerce) to be First name Last Initial (e.g., "John D." for "John Doe").</p>
<p>I got most of the way there with the following code in functions.php, but for some reason (perhaps because of how the comment/review was submi... | [
{
"answer_id": 178478,
"author": "Roman Candle Thoughts",
"author_id": 23211,
"author_profile": "https://wordpress.stackexchange.com/users/23211",
"pm_score": 2,
"selected": false,
"text": "<p>You are missing a \"NOT\" logical operator (!) in your if statement. \nYou want to say \"if com... | 2015/02/17 | [
"https://wordpress.stackexchange.com/questions/178466",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67654/"
] | I am trying to change the comment author name (or more specifically, the review author in WooCommerce) to be First name Last Initial (e.g., "John D." for "John Doe").
I got most of the way there with the following code in functions.php, but for some reason (perhaps because of how the comment/review was submitted) it t... | You are missing a "NOT" logical operator (!) in your if statement.
You want to say "if comment author IS NOT empty". As of now, the function is reading that the author is not empty and defaulting to your else statement that tells it to output the author's full name. Use the second block of code but make the following ... |
178,468 | <p>I have a question about changing the default sender From name/email on default wp_mail notifications (e.g., Lost Password response), but WITHOUT it messing up notifications being passed on by Gravity Forms.</p>
<p>I've found a few threads on changing the default From name/email, and this is what I ended up using. I... | [
{
"answer_id": 178475,
"author": "Kenny J",
"author_id": 67697,
"author_profile": "https://wordpress.stackexchange.com/users/67697",
"pm_score": 1,
"selected": false,
"text": "<p>I think I found the answer on another forum discussing using Contact Form7, with the same issue I was having.... | 2015/02/17 | [
"https://wordpress.stackexchange.com/questions/178468",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67697/"
] | I have a question about changing the default sender From name/email on default wp\_mail notifications (e.g., Lost Password response), but WITHOUT it messing up notifications being passed on by Gravity Forms.
I've found a few threads on changing the default From name/email, and this is what I ended up using. It did wor... | I think I found the answer on another forum discussing using Contact Form7, with the same issue I was having.
This is what I got from that thread and tried. It does appear to work and does appear to be only targeting email from the default 'Wordpress' sender name/email.
```
// Change default WP email sender
add_filte... |
178,484 | <p>How do I query by meta_value or title? </p>
<p>If I set meta_values,</p>
<pre><code>$args['meta_query'] = array(
'relation' => 'OR',
array(
'key' => 'model_name',
'value' => $thesearch,
'compare' => 'like'
)
);
</code></pre>
<p>they automatically get added as AND.</... | [
{
"answer_id": 178492,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 6,
"selected": true,
"text": "<p>Note that the <code>relation</code> part in the <code>meta_query</code> argument, is only used to define the r... | 2015/02/18 | [
"https://wordpress.stackexchange.com/questions/178484",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67686/"
] | How do I query by meta\_value or title?
If I set meta\_values,
```
$args['meta_query'] = array(
'relation' => 'OR',
array(
'key' => 'model_name',
'value' => $thesearch,
'compare' => 'like'
)
);
```
they automatically get added as AND.
This search would be:
```
WHERE title = 'S... | Note that the `relation` part in the `meta_query` argument, is only used to define the relation between the *sub meta* queries.
You can try this setup:
```
$args = [
'_meta_or_title' => $thesearch, // Our new custom argument!
'meta_query' => [
[
'key' => 'model_name',
... |
178,514 | <p>When I call <strong>the_content()</strong> i am getting</p>
<pre><code><div class="page" title="Page 1">
<div class="section">
<div class="layoutArea">
<div class="column">
<p>my text</p>
</div>
</div>
&l... | [
{
"answer_id": 178516,
"author": "cristian.raiber",
"author_id": 52524,
"author_profile": "https://wordpress.stackexchange.com/users/52524",
"pm_score": 0,
"selected": false,
"text": "<p>Usually, all those divs surround the <code>the_content();</code> function. Theme developers use these... | 2015/02/18 | [
"https://wordpress.stackexchange.com/questions/178514",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66405/"
] | When I call **the\_content()** i am getting
```
<div class="page" title="Page 1">
<div class="section">
<div class="layoutArea">
<div class="column">
<p>my text</p>
</div>
</div>
</div>
</div>
```
I would expect just
```
<p>my text</p>
```
I am confu... | As @TheDeadMedic pointed out, I was copying-pasting text directly from an external source, and that is why the wrappers were in the tinymce as well.
Those divs in my case, were copied from a pdf that was probably exported from illustrator or indesign. |
178,517 | <p>My categories are basically authors, and I would like to create a function to list them according to their surname. For example I'd like to have something like:</p>
<p>E:</p>
<ul>
<li>Heinz Erhardt</li>
<li>Albert Einstein</li>
<li>Eminem</li>
</ul>
<p>The problem is, I also have authors with only one name (like ... | [
{
"answer_id": 178518,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 4,
"selected": true,
"text": "<p>Use the <code>terms_clauses</code> filter, which passes all the various components of the query (fields, jo... | 2015/02/18 | [
"https://wordpress.stackexchange.com/questions/178517",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30939/"
] | My categories are basically authors, and I would like to create a function to list them according to their surname. For example I'd like to have something like:
E:
* Heinz Erhardt
* Albert Einstein
* Eminem
The problem is, I also have authors with only one name (like "Eminem") which I would also like to be sorted ac... | Use the `terms_clauses` filter, which passes all the various components of the query (fields, join, where, orderby, order & limits), and implement your own "search" argument:
```
function wpse_178511_get_terms_fields( $clauses, $taxonomies, $args ) {
if ( ! empty( $args['surname'] ) ) {
global $wpdb;
... |
178,533 | <p>I'm trying to convert a bunch of posts within a CPT to items within a Custom Taxonomy, where the post titles become the taxonomy names and the post content becomes the taxonomy descriptions. I have the below code (<a href="http://pastebin.com/Ukrmw2Jt" rel="nofollow">also here</a>) in a plugin but am not sure where ... | [
{
"answer_id": 178535,
"author": "David Gard",
"author_id": 10097,
"author_profile": "https://wordpress.stackexchange.com/users/10097",
"pm_score": 1,
"selected": false,
"text": "<p>First we create a new custom query containing all published posts of type <code>$post_type</code>, which y... | 2015/02/18 | [
"https://wordpress.stackexchange.com/questions/178533",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9764/"
] | I'm trying to convert a bunch of posts within a CPT to items within a Custom Taxonomy, where the post titles become the taxonomy names and the post content becomes the taxonomy descriptions. I have the below code ([also here](http://pastebin.com/Ukrmw2Jt)) in a plugin but am not sure where to add my CPT and Tax names. ... | Here's the solution that worked for me. I added the below code to a page template (page-test.php) and then created a page called "test," loaded the page, and all the CPTS were converted to taxonomies. Not sure if this happened when I created the page or when I loaded it... And then I quickly deleted the page template s... |
178,539 | <p>I install Tinymce editor to my site. And now i need to set the default direction to <code>RTL</code> not <code>LTR</code>.</p>
<p>I try this way but not work with me :-</p>
<pre><code>#tinymce p {
direction : rtl;
}
</code></pre>
<p>How can do that ??</p>
| [
{
"answer_id": 253721,
"author": "aytan",
"author_id": 111635,
"author_profile": "https://wordpress.stackexchange.com/users/111635",
"pm_score": 2,
"selected": false,
"text": "<pre><code> tinymce.init({\n selector: 'textarea#editor', \n directionality :\"rtl\"\n});\n</code>... | 2015/02/18 | [
"https://wordpress.stackexchange.com/questions/178539",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67551/"
] | I install Tinymce editor to my site. And now i need to set the default direction to `RTL` not `LTR`.
I try this way but not work with me :-
```
#tinymce p {
direction : rtl;
}
```
How can do that ?? | ```
tinymce.init({
selector: 'textarea#editor',
directionality :"rtl"
});
``` |
178,547 | <p>Here's a quick example of I am trying to achieve:</p>
<p><strong>I am using this filter:</strong></p>
<pre><code>add_filter('manage_edit-member_columns', 'set_custom_edit_member_columns');
function set_custom_edit_member_columns($columns) {
$columns['photo'] = "Photo";
return $columns;
}
</code></pre>
... | [
{
"answer_id": 178550,
"author": "Bruno Rodrigues",
"author_id": 42886,
"author_profile": "https://wordpress.stackexchange.com/users/42886",
"pm_score": 0,
"selected": false,
"text": "<p>Place the following function in your <code>functions.php</code>:</p>\n\n<pre><code>function wpse_1785... | 2015/02/18 | [
"https://wordpress.stackexchange.com/questions/178547",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30984/"
] | Here's a quick example of I am trying to achieve:
**I am using this filter:**
```
add_filter('manage_edit-member_columns', 'set_custom_edit_member_columns');
function set_custom_edit_member_columns($columns) {
$columns['photo'] = "Photo";
return $columns;
}
```
The function has one parameter passed ($co... | If you want to keep your log on the server, try using php's [`error_log()`](http://php.net/manual/en/function.error-log.php) which is more flexible than just writing to files on disk. Something along the lines of:
```
add_filter('manage_edit-member_columns', 'set_custom_edit_member_columns');
function set_custom_edit... |
178,564 | <p>I want to remove the last updated / last modified date from pages (not posts) via functions.php (could this be done by making that hook __null?)</p>
<p>The goal is to remove the google search result description date time stamp that shows up because of the date modified code. I only want the function to run on pages... | [
{
"answer_id": 178570,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p>It depends on what the template uses to output whatever you're trying to remove. If you look in source at whatever... | 2015/02/18 | [
"https://wordpress.stackexchange.com/questions/178564",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62312/"
] | I want to remove the last updated / last modified date from pages (not posts) via functions.php (could this be done by making that hook \_\_null?)
The goal is to remove the google search result description date time stamp that shows up because of the date modified code. I only want the function to run on pages (since ... | It depends on what the template uses to output whatever you're trying to remove. If you look in source at whatever function is outputting what you want to remove, they each have a filter to let you modify output where you can `__return_false` instead, however, if there's text or markup surrounding those template tags, ... |
178,566 | <p>I have an Elegant Estate Theme and I am using Multiple Category Selection to display some posts, the Result Page is displaying the Feature SlideShow on the top, and I want to eliminate this; I want it to work just as Wordpress Search displays the result (without the Feature Slider).</p>
<p>I found out that the Mult... | [
{
"answer_id": 178572,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p>You could <a href=\"http://codex.wordpress.org/Template_Hierarchy#Filter_Hierarchy\" rel=\"nofollow\">filter <code... | 2015/02/18 | [
"https://wordpress.stackexchange.com/questions/178566",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67757/"
] | I have an Elegant Estate Theme and I am using Multiple Category Selection to display some posts, the Result Page is displaying the Feature SlideShow on the top, and I want to eliminate this; I want it to work just as Wordpress Search displays the result (without the Feature Slider).
I found out that the Multiple Categ... | You could [filter `home_template`](http://codex.wordpress.org/Template_Hierarchy#Filter_Hierarchy), check for the presence whatever `$_GET` var is reliably set for each of those requests, and load a different template for those cases.
```
function wpd_home_template( $home_template = '' ){
if( isset( $_GET['search_... |
178,577 | <p>I need to modify the outputted <code><title></title></code> tag of a few specific templates, and it has to be done in php so I can dynamically generate content for it. I've been playing around with these two snippets of code to get it to work, but so far the only change I've gotten is a duplicated title ... | [
{
"answer_id": 178589,
"author": "Pat Gilmour",
"author_id": 48679,
"author_profile": "https://wordpress.stackexchange.com/users/48679",
"pm_score": 2,
"selected": false,
"text": "<p>Try this to create your custom titles.</p>\n\n<pre><code>remove_filter( 'wp_title', 'genesis_default_titl... | 2015/02/18 | [
"https://wordpress.stackexchange.com/questions/178577",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/64943/"
] | I need to modify the outputted `<title></title>` tag of a few specific templates, and it has to be done in php so I can dynamically generate content for it. I've been playing around with these two snippets of code to get it to work, but so far the only change I've gotten is a duplicated title tag:
```
remove_filter('w... | Try this to create your custom titles.
```
remove_filter( 'wp_title', 'genesis_default_title', 10, 3 ); //Default title
remove_action( 'genesis_site_title', 'genesis_seo_site_title' ); //Genesis Extra Stuff
remove_action( 'genesis_site_description', 'genesis_seo_site_description' ); //Genesis Extra Stuff
add_filter( ... |
178,586 | <p>I am working with categories (cities) and subcategories with the same menu (for example: cars, animals, houses).</p>
<p>Therefore right now my categories structure looks like this:</p>
<pre><code>- London
-- cars
-- animals
-- houses
- Manchester
--cars
--animals
--houses
</code></pre>
<p>The slugs for each su... | [
{
"answer_id": 178608,
"author": "Privateer",
"author_id": 66020,
"author_profile": "https://wordpress.stackexchange.com/users/66020",
"pm_score": 2,
"selected": true,
"text": "<p>You could use the template_redirect hook to check and see if your post is a category and then whether it is ... | 2015/02/18 | [
"https://wordpress.stackexchange.com/questions/178586",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66167/"
] | I am working with categories (cities) and subcategories with the same menu (for example: cars, animals, houses).
Therefore right now my categories structure looks like this:
```
- London
-- cars
-- animals
-- houses
- Manchester
--cars
--animals
--houses
```
The slugs for each subcategory (as it seems they have t... | You could use the template\_redirect hook to check and see if your post is a category and then whether it is a sub-category ... and if so, force a different template.
For example (assuming you are using wordpress categories)
```
function my_maybe_override_category_template( $template ) {
# Make sure you are about... |
178,588 | <p>I have an array:</p>
<pre><code> $cats = array('Hobbes', 'Simba', 'Grumpy Cat');
</code></pre>
<p>I would like to create a custom endpoint called "<a href="http://example.com/cats">http://example.com/cats</a>". Whenever you visit this URL, have it output the array as JSON:</p>
<pre><code> header('Content-Type: ap... | [
{
"answer_id": 178590,
"author": "Eric_WVGG",
"author_id": 67768,
"author_profile": "https://wordpress.stackexchange.com/users/67768",
"pm_score": 0,
"selected": false,
"text": "<p>I’m sure there are better ways to do it, but I’d add this to functions.php…</p>\n\n<pre><code>add_action('p... | 2015/02/18 | [
"https://wordpress.stackexchange.com/questions/178588",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38881/"
] | I have an array:
```
$cats = array('Hobbes', 'Simba', 'Grumpy Cat');
```
I would like to create a custom endpoint called "<http://example.com/cats>". Whenever you visit this URL, have it output the array as JSON:
```
header('Content-Type: application/json');
$cats = array('Hobbes', 'Simba', 'Grumpy Cat');
echo ... | You can use `pre_get_posts` as suggested but simply check the global `$wp` object for the request url.. like so:
```
add_action( 'pre_get_posts', function ($query ){
global $wp;
if ( !is_admin() && $query->is_main_query() ) {
if ($wp->request == 'cats'){
header('Content-Type: application/j... |
178,669 | <p>So, I have a widget that I only want to show it to the page author.</p>
<p>I used the following logic: is_author()</p>
<p>However it does not seem to work (it shows non-author)</p>
<p>Am I using this logic right?</p>
<p>Any suggestions?</p>
<p>Thank you</p>
| [
{
"answer_id": 178679,
"author": "Sean Grant",
"author_id": 67105,
"author_profile": "https://wordpress.stackexchange.com/users/67105",
"pm_score": 3,
"selected": true,
"text": "<p>is_author() is only for Archive pages. \nQuote from the Codex: </p>\n\n<blockquote>\n <p>is_author() check... | 2015/02/19 | [
"https://wordpress.stackexchange.com/questions/178669",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67604/"
] | So, I have a widget that I only want to show it to the page author.
I used the following logic: is\_author()
However it does not seem to work (it shows non-author)
Am I using this logic right?
Any suggestions?
Thank you | is\_author() is only for Archive pages.
Quote from the Codex:
>
> is\_author() checks if an Author archive page is being displayed
>
>
>
So viewing a single Post or Page isn't going to get a TRUE from is\_author().
I think you'll want something more like this:
```
global $post,$current_user; // get the global... |
178,681 | <p>I have a client whose dev team set up a wordpress site for development (dev server on a subdomain), but didn't check the "Search Engine Visibility" checkbox when creating the site and now the site is showing up in the google search engine results.</p>
<p>Will checking the box now remove it from google or are they s... | [
{
"answer_id": 178679,
"author": "Sean Grant",
"author_id": 67105,
"author_profile": "https://wordpress.stackexchange.com/users/67105",
"pm_score": 3,
"selected": true,
"text": "<p>is_author() is only for Archive pages. \nQuote from the Codex: </p>\n\n<blockquote>\n <p>is_author() check... | 2015/02/19 | [
"https://wordpress.stackexchange.com/questions/178681",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67810/"
] | I have a client whose dev team set up a wordpress site for development (dev server on a subdomain), but didn't check the "Search Engine Visibility" checkbox when creating the site and now the site is showing up in the google search engine results.
Will checking the box now remove it from google or are they screwed? | is\_author() is only for Archive pages.
Quote from the Codex:
>
> is\_author() checks if an Author archive page is being displayed
>
>
>
So viewing a single Post or Page isn't going to get a TRUE from is\_author().
I think you'll want something more like this:
```
global $post,$current_user; // get the global... |
178,684 | <p>i want to remove screen options from wordpress admin panel and remove default dashboard items and add quick draft widget in dashboard for custom post type "gallery".
<img src="https://i.stack.imgur.com/4E4sP.png" alt="enter image description here"></p>
| [
{
"answer_id": 178688,
"author": "mikemanger",
"author_id": 48357,
"author_profile": "https://wordpress.stackexchange.com/users/48357",
"pm_score": 2,
"selected": true,
"text": "<p>You can remove the Screen Options with the 'screen_options_show_screen' filter.</p>\n\n<pre><code>function ... | 2015/02/19 | [
"https://wordpress.stackexchange.com/questions/178684",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67596/"
] | i want to remove screen options from wordpress admin panel and remove default dashboard items and add quick draft widget in dashboard for custom post type "gallery".
 | You can remove the Screen Options with the 'screen\_options\_show\_screen' filter.
```
function myplugin_disable_screen_options( $show_screen ) {
// Logic to allow admins to still access the menu
if ( current_user_can( 'manage_options' ) ) {
return $show_screen;
}
return false;
}
add_filter( 's... |
178,693 | <p>I Write Code to Save data in the Wordpress database table (table name is wp_fafa)</p>
<p>But Can't Save data in </p>
<pre><code>$qry = $wpdb->query( "INSERT INTO `wp_fafa` (titile,liveprice,changing,lowest,topest,time) VALUES ('" . trim($row->item(0)->nodeValue) . "','" . trim($row->item(2)->nodeVal... | [
{
"answer_id": 178688,
"author": "mikemanger",
"author_id": 48357,
"author_profile": "https://wordpress.stackexchange.com/users/48357",
"pm_score": 2,
"selected": true,
"text": "<p>You can remove the Screen Options with the 'screen_options_show_screen' filter.</p>\n\n<pre><code>function ... | 2015/02/19 | [
"https://wordpress.stackexchange.com/questions/178693",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48589/"
] | I Write Code to Save data in the Wordpress database table (table name is wp\_fafa)
But Can't Save data in
```
$qry = $wpdb->query( "INSERT INTO `wp_fafa` (titile,liveprice,changing,lowest,topest,time) VALUES ('" . trim($row->item(0)->nodeValue) . "','" . trim($row->item(2)->nodeValue) . "','" . trim($row->item(4)->n... | You can remove the Screen Options with the 'screen\_options\_show\_screen' filter.
```
function myplugin_disable_screen_options( $show_screen ) {
// Logic to allow admins to still access the menu
if ( current_user_can( 'manage_options' ) ) {
return $show_screen;
}
return false;
}
add_filter( 's... |
178,707 | <p>I'm unclear on the <code>get_the_foo()</code> style of functions, for example <code>get_the_permalink()</code>.</p>
<p>My main question is: when this is performed in The Loop, is another SQL query executed (besides the original <code>WP_Query()</code>)?</p>
<p>But: if performed by itself, e.g. <code>get_the_permal... | [
{
"answer_id": 178688,
"author": "mikemanger",
"author_id": 48357,
"author_profile": "https://wordpress.stackexchange.com/users/48357",
"pm_score": 2,
"selected": true,
"text": "<p>You can remove the Screen Options with the 'screen_options_show_screen' filter.</p>\n\n<pre><code>function ... | 2015/02/19 | [
"https://wordpress.stackexchange.com/questions/178707",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52625/"
] | I'm unclear on the `get_the_foo()` style of functions, for example `get_the_permalink()`.
My main question is: when this is performed in The Loop, is another SQL query executed (besides the original `WP_Query()`)?
But: if performed by itself, e.g. `get_the_permalink($someId)`, a query *is* executed, correct? | You can remove the Screen Options with the 'screen\_options\_show\_screen' filter.
```
function myplugin_disable_screen_options( $show_screen ) {
// Logic to allow admins to still access the menu
if ( current_user_can( 'manage_options' ) ) {
return $show_screen;
}
return false;
}
add_filter( 's... |
178,744 | <p>So I'm displaying 3 different layout types, one for pages, one for posts (blog, archives, tags, search etc..) and one for single posts.</p>
<p>Originally, I was using this to decide whether I was on a page which displayed posts:</p>
<pre><code>if ( is_home() ||
is_category() ||
is_tag() ||
is_archive... | [
{
"answer_id": 178766,
"author": "Evan Van Slooten",
"author_id": 67781,
"author_profile": "https://wordpress.stackexchange.com/users/67781",
"pm_score": 1,
"selected": false,
"text": "<p>To answer the question, no it's not the same. It is cleaner, but for example a home page can have tr... | 2015/02/20 | [
"https://wordpress.stackexchange.com/questions/178744",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10946/"
] | So I'm displaying 3 different layout types, one for pages, one for posts (blog, archives, tags, search etc..) and one for single posts.
Originally, I was using this to decide whether I was on a page which displayed posts:
```
if ( is_home() ||
is_category() ||
is_tag() ||
is_archive() ||
is_tax() |... | Both will do the same job in the end of the day. You can however improve on the first code.
`is_archive()` returns `true` on all archives page, which includes the following
* taxonomy archive pages
* category archive pages
* date archive pages
* author archive pages
* tag archive pages
So, if you need to target all ... |
178,750 | <p>I am creating a plugin that needs to display external data, not wordpress posts.</p>
<p>What I have done: registered rewrites so wp recognizes my archive/single URLs, hooked into <code>template_include</code> to direct it to use my template if the requested URL was one of mine, and then in the template I call a fun... | [
{
"answer_id": 178766,
"author": "Evan Van Slooten",
"author_id": 67781,
"author_profile": "https://wordpress.stackexchange.com/users/67781",
"pm_score": 1,
"selected": false,
"text": "<p>To answer the question, no it's not the same. It is cleaner, but for example a home page can have tr... | 2015/02/20 | [
"https://wordpress.stackexchange.com/questions/178750",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67850/"
] | I am creating a plugin that needs to display external data, not wordpress posts.
What I have done: registered rewrites so wp recognizes my archive/single URLs, hooked into `template_include` to direct it to use my template if the requested URL was one of mine, and then in the template I call a function to load the ext... | Both will do the same job in the end of the day. You can however improve on the first code.
`is_archive()` returns `true` on all archives page, which includes the following
* taxonomy archive pages
* category archive pages
* date archive pages
* author archive pages
* tag archive pages
So, if you need to target all ... |
178,762 | <p>I have added a select box in the Post meta. Here is the code, and it works fine. My question is, do I need to sanitize the values before updating the post meta? If yes, how it should be done?</p>
<p>This is how I'm adding the meta field:</p>
<pre><code><?php $value = get_post_meta( $post->ID, 'my_options', t... | [
{
"answer_id": 178770,
"author": "Evan Van Slooten",
"author_id": 67781,
"author_profile": "https://wordpress.stackexchange.com/users/67781",
"pm_score": 0,
"selected": false,
"text": "<p>You can use any of the sanitation functions built into Wordpress (such as <a href=\"http://codex.wor... | 2015/02/20 | [
"https://wordpress.stackexchange.com/questions/178762",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67310/"
] | I have added a select box in the Post meta. Here is the code, and it works fine. My question is, do I need to sanitize the values before updating the post meta? If yes, how it should be done?
This is how I'm adding the meta field:
```
<?php $value = get_post_meta( $post->ID, 'my_options', true ); ?>
<select name="my_... | When accepting user data inputs, I think that data validation must be performed if possible, not only sanitization. For example, you could expect a number, a bool value, a text string (even when the input is a selectbox it can have a string value), etc. You can santize for that data types; then you can go further and v... |
178,780 | <p>Im using the next post link function of WP to show next and previous navigation links to the "next post in same category" all good with this...the issue i have is that when I'm in the "last" post of a category, the "NEXT" link appears anyway and doing what i dont want: linking to a different category 1st post. the s... | [
{
"answer_id": 178789,
"author": "David Gard",
"author_id": 10097,
"author_profile": "https://wordpress.stackexchange.com/users/10097",
"pm_score": 4,
"selected": true,
"text": "<p>You can do this by using <a href=\"http://codex.wordpress.org/Function_Reference/previous_post_link\" rel=\... | 2015/02/20 | [
"https://wordpress.stackexchange.com/questions/178780",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50943/"
] | Im using the next post link function of WP to show next and previous navigation links to the "next post in same category" all good with this...the issue i have is that when I'm in the "last" post of a category, the "NEXT" link appears anyway and doing what i dont want: linking to a different category 1st post. the same... | You can do this by using [`previous_post_link()`](http://codex.wordpress.org/Function_Reference/previous_post_link) and [`next_post_link()`](http://codex.wordpress.org/Function_Reference/next_post_link).
These functions will create the links for you, and you should be able to get rid of all of the logic you are using ... |
178,816 | <p>I'm using the following code to list all years from my blog, I guess we can call it an archive.</p>
<pre><code><?php
$years = $wpdb->get_col("SELECT DISTINCT YEAR(post_date) FROM $wpdb->posts ORDER BY post_date DESC");
foreach($years as $year) : ?>
<?php echo $year ?>
<?php endforeach; ?>... | [
{
"answer_id": 178941,
"author": "David Gard",
"author_id": 10097,
"author_profile": "https://wordpress.stackexchange.com/users/10097",
"pm_score": 2,
"selected": false,
"text": "<h1>The Easy Way</h1>\n\n<p>This is by far and away the easiest approach to this, but unless you are willing ... | 2015/02/20 | [
"https://wordpress.stackexchange.com/questions/178816",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59749/"
] | I'm using the following code to list all years from my blog, I guess we can call it an archive.
```
<?php
$years = $wpdb->get_col("SELECT DISTINCT YEAR(post_date) FROM $wpdb->posts ORDER BY post_date DESC");
foreach($years as $year) : ?>
<?php echo $year ?>
<?php endforeach; ?>
```
What I'd like to achieve thoug... | The Easy Way
============
This is by far and away the easiest approach to this, but unless you are willing to be a little bit flexible with how you present your archive it's not for you.
The easy solution is achieved using the [`wp_get_archives()`](http://codex.wordpress.org/Function_Reference/wp_get_archives) functi... |
178,858 | <p>I've been trying to rebuild one of my websites story archives in Drupal. I have a personal website I wouldn't mind putting in Wordpress, but I want an easy way to create structured documents. That is to say I wanr a parent Story page, that has links and hierarchy for the Chapters under it. Is this doable in Wordpres... | [
{
"answer_id": 178941,
"author": "David Gard",
"author_id": 10097,
"author_profile": "https://wordpress.stackexchange.com/users/10097",
"pm_score": 2,
"selected": false,
"text": "<h1>The Easy Way</h1>\n\n<p>This is by far and away the easiest approach to this, but unless you are willing ... | 2015/02/20 | [
"https://wordpress.stackexchange.com/questions/178858",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43799/"
] | I've been trying to rebuild one of my websites story archives in Drupal. I have a personal website I wouldn't mind putting in Wordpress, but I want an easy way to create structured documents. That is to say I wanr a parent Story page, that has links and hierarchy for the Chapters under it. Is this doable in Wordpress? | The Easy Way
============
This is by far and away the easiest approach to this, but unless you are willing to be a little bit flexible with how you present your archive it's not for you.
The easy solution is achieved using the [`wp_get_archives()`](http://codex.wordpress.org/Function_Reference/wp_get_archives) functi... |
178,892 | <p>I have a custom tag-search feature, which allows people to search multiple tags to return relevant posts. Say they want to see posts that are tagged both 'Wordpress' and 'Tutorials'. I'm using the <code>template_include</code> filter, like so:</p>
<pre><code>public static function template_redirect( $template ) {
... | [
{
"answer_id": 179242,
"author": "chifliiiii",
"author_id": 4130,
"author_profile": "https://wordpress.stackexchange.com/users/4130",
"pm_score": 0,
"selected": false,
"text": "<p>Try the following:</p>\n\n<pre><code>public static function pre_get_posts($query) {\n if( !isset($_GET['t... | 2015/02/21 | [
"https://wordpress.stackexchange.com/questions/178892",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16368/"
] | I have a custom tag-search feature, which allows people to search multiple tags to return relevant posts. Say they want to see posts that are tagged both 'Wordpress' and 'Tutorials'. I'm using the `template_include` filter, like so:
```
public static function template_redirect( $template ) {
if( isset($_GET['tag-s... | Your problem is that you are not resetting all the needed query variables, like `WP_Query::$is_page`, `WP_Query::$is_single` and `WP_Query::$is_archive`.
Also note that `'pre_get_posts'` is fired for all queries, the main and the secondaries, so you should check that you are working on the main query.
Finally, when y... |
178,911 | <p>I have created this widget function to show a subscription form but from here i am not able to get the the values of input fields when someone submit it. Please help to get post values of the form.</p>
<pre><code>function widget($args, $instance) {
extract( $args );
// these are the widget options
$titl... | [
{
"answer_id": 178950,
"author": "Greg Piwowarski",
"author_id": 67944,
"author_profile": "https://wordpress.stackexchange.com/users/67944",
"pm_score": 0,
"selected": false,
"text": "<p>Can't you use a plugin for that? There is a nice mailchimp plugin available with a widget and submiss... | 2015/02/21 | [
"https://wordpress.stackexchange.com/questions/178911",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67926/"
] | I have created this widget function to show a subscription form but from here i am not able to get the the values of input fields when someone submit it. Please help to get post values of the form.
```
function widget($args, $instance) {
extract( $args );
// these are the widget options
$title = apply_filt... | Your form needs to have `method="post"` and `action="someScript.php"` defined. It will send the post variables to wherever you deifine in your `action=""`
```
<form method="post" action="someScript.php" >
<p>
<label for="db_sub_name">Name</label>
<input type="text" name="db_sub_name" id="db_sub_name" val... |
178,940 | <p>Trying to show featured posts on home using catID,but it is being duplicated. Is there any way to prevent it from duplicating:</p>
<pre><code><?php
query_posts("posts_per_page=1&cat=1");
if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<h2><a href="<?php the_permalink(); ?>">... | [
{
"answer_id": 178924,
"author": "gurudeb",
"author_id": 12106,
"author_profile": "https://wordpress.stackexchange.com/users/12106",
"pm_score": 1,
"selected": false,
"text": "<p>Have look at add_image_size and add to your theme's functions.php file:</p>\n\n<p><a href=\"http://codex.word... | 2015/02/21 | [
"https://wordpress.stackexchange.com/questions/178940",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59698/"
] | Trying to show featured posts on home using catID,but it is being duplicated. Is there any way to prevent it from duplicating:
```
<?php
query_posts("posts_per_page=1&cat=1");
if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php t... | Have look at add\_image\_size and add to your theme's functions.php file:
<http://codex.wordpress.org/Function_Reference/add_image_size> |
179,011 | <p>I am creating a custom theme with some widgets. In the theme, to make it easier for my client to update, I am using SiteOrigin's Page Builder plugin, which uses widgets to display content. I am creating an events list widget which will work with a custom post type. I want the widget to display a map of the area, bu... | [
{
"answer_id": 179017,
"author": "skribe",
"author_id": 67491,
"author_profile": "https://wordpress.stackexchange.com/users/67491",
"pm_score": 0,
"selected": false,
"text": "<p>WordPress has a function for that already. <code>is_active_widget</code> As the codex points out you must use ... | 2015/02/22 | [
"https://wordpress.stackexchange.com/questions/179011",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36204/"
] | I am creating a custom theme with some widgets. In the theme, to make it easier for my client to update, I am using SiteOrigin's Page Builder plugin, which uses widgets to display content. I am creating an events list widget which will work with a custom post type. I want the widget to display a map of the area, but ON... | You should make the check inside the widget class, unless you don't have a choice. The example in the codex is pretty much what you're looking for:
```
class cbs_map_widget extends WP_Widget{
function cbs_map_widget(){
$this->WP_Widget('cbsmaps', __('Widget Name'), array('classname' => 'cbsmaps', 'description' ... |
179,054 | <p>I'm trying to get a menu items created from wordpress admin panel.</p>
<p>To do this I followed the instructions codex:
<a href="http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items" rel="nofollow">http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items</a></p>
<pre><code>// Get the nav ... | [
{
"answer_id": 179017,
"author": "skribe",
"author_id": 67491,
"author_profile": "https://wordpress.stackexchange.com/users/67491",
"pm_score": 0,
"selected": false,
"text": "<p>WordPress has a function for that already. <code>is_active_widget</code> As the codex points out you must use ... | 2015/02/23 | [
"https://wordpress.stackexchange.com/questions/179054",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68004/"
] | I'm trying to get a menu items created from wordpress admin panel.
To do this I followed the instructions codex:
<http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items>
```
// Get the nav menu based on $menu_name (same as 'theme_location' or 'menu' arg to wp_nav_menu)
// This code based on wp_nav_me... | You should make the check inside the widget class, unless you don't have a choice. The example in the codex is pretty much what you're looking for:
```
class cbs_map_widget extends WP_Widget{
function cbs_map_widget(){
$this->WP_Widget('cbsmaps', __('Widget Name'), array('classname' => 'cbsmaps', 'description' ... |
179,070 | <p>I am trying to use <code>wp_redirect()</code> to redirect the user after successfully submitting a signup form on the page.</p>
<p>It's not working and shows the following error:</p>
<blockquote>
<p>Warning: Cannot modify header information - headers already sent by
(output started at
/Applications/MAMP/htdo... | [
{
"answer_id": 179071,
"author": "Abhisek Malakar",
"author_id": 62784,
"author_profile": "https://wordpress.stackexchange.com/users/62784",
"pm_score": 2,
"selected": false,
"text": "<pre><code>add_action('template_redirect', function(){\nif(isset($_POST['subscriptio'])){// make this co... | 2015/02/23 | [
"https://wordpress.stackexchange.com/questions/179070",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68011/"
] | I am trying to use `wp_redirect()` to redirect the user after successfully submitting a signup form on the page.
It's not working and shows the following error:
>
> Warning: Cannot modify header information - headers already sent by
> (output started at
> /Applications/MAMP/htdocs/theme/wp-content/themes/test/head... | Found the answer [(via)](https://wordpress.stackexchange.com/questions/76991/wp-redirect-not-working-after-submitting-form/76993#76993)
Instead of using the function directly, I added an action to "wp\_loaded", that makes sure that it gets loaded before any headers are sent.
```
<?php
add_action ('wp_loaded', 'my_cus... |
179,078 | <p>I have multiple local installations of WordPress and want to have a single Must Use Plugins directory for all my local sites.</p>
<p>Is there anything I can add to wp-config for instance that will let me have a single folder which can be used for all my sites? Or perhaps another approach?</p>
<p>For instance:</p>
... | [
{
"answer_id": 179079,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 3,
"selected": true,
"text": "<p>Yes, you can set the <code>WPMU_PLUGIN_DIR</code> constant in the config file of each of the sites (and <... | 2015/02/23 | [
"https://wordpress.stackexchange.com/questions/179078",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38077/"
] | I have multiple local installations of WordPress and want to have a single Must Use Plugins directory for all my local sites.
Is there anything I can add to wp-config for instance that will let me have a single folder which can be used for all my sites? Or perhaps another approach?
For instance:
/root/sites/site1/..... | Yes, you can set the `WPMU_PLUGIN_DIR` constant in the config file of each of the sites (and `WPMU_PLUGIN_URL` for the url).
By default it is defined as:
```
WP_CONTENT_DIR . '/mu-plugins'
``` |
179,090 | <p>I try to add panel to my customizer but code below doesn't work (panel don't show in customizer container). My code:</p>
<pre><code>add_action( 'customize_register', 'customizer_test' );
function customizer_test($wp_customize) {
$wp_customize->add_panel( 'panel_id', array(
'priority' => 10,
... | [
{
"answer_id": 232084,
"author": "Calvin Koepke",
"author_id": 80821,
"author_profile": "https://wordpress.stackexchange.com/users/80821",
"pm_score": 2,
"selected": false,
"text": "<p>First, use a different id for your panel than <code>panel_id</code>.</p>\n\n<p>Your sections will not s... | 2015/02/23 | [
"https://wordpress.stackexchange.com/questions/179090",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47607/"
] | I try to add panel to my customizer but code below doesn't work (panel don't show in customizer container). My code:
```
add_action( 'customize_register', 'customizer_test' );
function customizer_test($wp_customize) {
$wp_customize->add_panel( 'panel_id', array(
'priority' => 10,
'capability'... | You want to **add\_setting** and **add\_control** to your panel to work.
For example:
```
function panel($wp_customize){
$wp_customize->add_panel('some_panel',array(
'title'=>'Panel1',
'description'=> 'This is panel Description',
'priority'=> 10,
));
$wp_customize->add_section('section',array(
'titl... |
179,097 | <p>I have custom post type named <em>soto_property</em> in which I have added three <em>wp_editor</em> as post meta, using this code -</p>
<pre><code> wp_editor( htmlspecialchars_decode($valueeee1),
'propertyEditor1',
$settings = array('textarea_name'=>'detail',
... | [
{
"answer_id": 179100,
"author": "Karolína Vyskočilová",
"author_id": 64771,
"author_profile": "https://wordpress.stackexchange.com/users/64771",
"pm_score": 2,
"selected": false,
"text": "<p>it looks as already answered <a href=\"https://wordpress.stackexchange.com/questions/97889/qtran... | 2015/02/23 | [
"https://wordpress.stackexchange.com/questions/179097",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67983/"
] | I have custom post type named *soto\_property* in which I have added three *wp\_editor* as post meta, using this code -
```
wp_editor( htmlspecialchars_decode($valueeee1),
'propertyEditor1',
$settings = array('textarea_name'=>'detail',
'editor_class'=>'pr... | it looks as already answered [here on stackexchange](https://wordpress.stackexchange.com/questions/97889/qtranslate-for-custom-post-type) (really detailed way), as first you can try:
```
add_filter('soto_property','qtrans_convertURL');
```
Anyway, have a look here on [qtranslate slug plugin](https://wordpress.org/p... |
179,137 | <p>I would like to remove the following two script and one style tags. They appear to be added by the Yoast SEO plugin, but looking through their plugin files yields nothing promising. Does anyone know where these are enqueued or another way to remove them? </p>
<pre><code><!-- / Yoast WordPress SEO plugin. -->
... | [
{
"answer_id": 179146,
"author": "Przemek Maczewski",
"author_id": 68013,
"author_profile": "https://wordpress.stackexchange.com/users/68013",
"pm_score": 3,
"selected": true,
"text": "<p>How this line (9th) is created within your theme code?</p>\n\n<pre><code><script type=\"text/java... | 2015/02/23 | [
"https://wordpress.stackexchange.com/questions/179137",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67629/"
] | I would like to remove the following two script and one style tags. They appear to be added by the Yoast SEO plugin, but looking through their plugin files yields nothing promising. Does anyone know where these are enqueued or another way to remove them?
```
<!-- / Yoast WordPress SEO plugin. -->
<script type="text/j... | How this line (9th) is created within your theme code?
```
<script type="text/javascript" src="/wp-content/themes/blankslate/js/jquery-1.11.1.min.js"></script>
```
If it is hard-coded in header.php, then I would recommend to remove it. [Scripts should be enqueued](http://codex.wordpress.org/Function_Reference/wp_enq... |
179,140 | <p>I'm getting the following error in my <code>debug.log</code>:</p>
<pre><code>PHP Notice: Trying to get property of non-object in /my-wesbite/wp-content/themes/express/header.php on line 36
</code></pre>
<p>This is line 36 of <code>header.php</code> in my theme:</p>
<pre><code><body id="page-<?php echo $pos... | [
{
"answer_id": 179156,
"author": "Tim Malone",
"author_id": 46066,
"author_profile": "https://wordpress.stackexchange.com/users/46066",
"pm_score": 0,
"selected": false,
"text": "<p>Keep in mind this will only work if you're on a single page or post, because when you're displaying the ou... | 2015/02/23 | [
"https://wordpress.stackexchange.com/questions/179140",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14190/"
] | I'm getting the following error in my `debug.log`:
```
PHP Notice: Trying to get property of non-object in /my-wesbite/wp-content/themes/express/header.php on line 36
```
This is line 36 of `header.php` in my theme:
```
<body id="page-<?php echo $post->post_name;?>" <?php body_class(); ?> data-site-url="<?php echo... | A better method for what you are trying to achieve
==================================================
This answer is not about the php error you are getting. You need these classes for styling your website right?
Put the following code in your functions.php
```
// A better body class
function condensed_body_class($c... |
179,145 | <p>I need to add a plugin to a theme and enable it automatically once the theme is activated. Would also like to change its settings if possible. This is the plugin I am trying to include: <a href="https://wordpress.org/plugins/subheading/" rel="nofollow">https://wordpress.org/plugins/subheading/</a></p>
<p>I tried ad... | [
{
"answer_id": 179147,
"author": "Joey Yax",
"author_id": 6148,
"author_profile": "https://wordpress.stackexchange.com/users/6148",
"pm_score": 2,
"selected": false,
"text": "<p>There's no method to bundle a plugin with a theme install. Your best bet would be to check if a plugin is inst... | 2015/02/23 | [
"https://wordpress.stackexchange.com/questions/179145",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63443/"
] | I need to add a plugin to a theme and enable it automatically once the theme is activated. Would also like to change its settings if possible. This is the plugin I am trying to include: <https://wordpress.org/plugins/subheading/>
I tried adding the plugin inside the theme plugin folder but it does not show up on WP pl... | The user decides
----------------
To answer your last question first:
>
> I tried adding the plugin inside the theme plugin folder [...] What am I doing wrong?
>
>
>
You are trying to bundle functionality into a theme. That is the wrong thing in the first place. Themes offer presentation - Plugins offers functio... |
179,150 | <p>Is there a way to get the block of code below to extract a list of given user information as it creates the page for the new user. It creates new page for new user as supposed but I'd like it to alos extract and display some information from the user profile.</p>
<pre><code>function my_create_page($user_id){
$t... | [
{
"answer_id": 179151,
"author": "Tim Malone",
"author_id": 46066,
"author_profile": "https://wordpress.stackexchange.com/users/46066",
"pm_score": 1,
"selected": false,
"text": "<p>If I understand your question correctly, you should be able to grab the information you're after from $the... | 2015/02/23 | [
"https://wordpress.stackexchange.com/questions/179150",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4401/"
] | Is there a way to get the block of code below to extract a list of given user information as it creates the page for the new user. It creates new page for new user as supposed but I'd like it to alos extract and display some information from the user profile.
```
function my_create_page($user_id){
$the_user = get_... | If I understand your question correctly, you should be able to grab the information you're after from $the\_user.
If you use:
```
$my_post['post_content'] = print_r($the_user,true);
```
you should be able to see all the available user information in the page. Once you know exactly what you want, you can echo it out... |
179,155 | <p>I'm attempting to use <code>get_users</code> to select users with only a certain meta value. In this case the meta key is <code>extraInfo</code> but the the values are in a serialized array. Can I pull users out like this? This is what I've been trying with no luck:</p>
<pre><code>$meta_key = 'extraInfo[zip]';
$... | [
{
"answer_id": 179200,
"author": "Abhisek Malakar",
"author_id": 62784,
"author_profile": "https://wordpress.stackexchange.com/users/62784",
"pm_score": 0,
"selected": false,
"text": "<pre><code> <?php\n /**\n * are you sure that your meta value is ok... | 2015/02/23 | [
"https://wordpress.stackexchange.com/questions/179155",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33921/"
] | I'm attempting to use `get_users` to select users with only a certain meta value. In this case the meta key is `extraInfo` but the the values are in a serialized array. Can I pull users out like this? This is what I've been trying with no luck:
```
$meta_key = 'extraInfo[zip]';
$meta_value = $zip;
$query = get_user... | The answer is, this can't be done with any efficiency. The best thing to do is pull the data out of the serialized array and save each as their own key/value pair in the `wp_usermeta` table. My key was `extraInfo` and the values I needed were serialized in the value. This is the script I've used to create new keys and ... |
179,162 | <p>I am experiencing some odd behavior, that apparently happens "out of the box" with WordPress.</p>
<p>If I upload a file through the media manager called: <code>services.jpg;</code> then go try to create a page with the permalink <code>http://example.com/services/;</code> The slug <code>services-2</code> is given in... | [
{
"answer_id": 179165,
"author": "Tim Malone",
"author_id": 46066,
"author_profile": "https://wordpress.stackexchange.com/users/46066",
"pm_score": 1,
"selected": false,
"text": "<p>Tom's comment is correct, in that this is normal behaviour and there is not much you can do to stop it.</p... | 2015/02/24 | [
"https://wordpress.stackexchange.com/questions/179162",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32799/"
] | I am experiencing some odd behavior, that apparently happens "out of the box" with WordPress.
If I upload a file through the media manager called: `services.jpg;` then go try to create a page with the permalink `http://example.com/services/;` The slug `services-2` is given instead, because the attachment is already us... | Thank you for the response everyone. I played around with macemmek's solution and I think it led me to an even better solution:
```
add_filter( 'wp_unique_post_slug_is_bad_attachment_slug', '__return_true' );
```
That is all that is needed. This will automatically 'skip' the default assigned slug on any attachment. ... |
179,167 | <p>So, this is how WordPress is saving my CPT meta:</p>
<pre><code> array(8) {
["product_id"]=> array(1) { [0]=> string(10) "abcdefg987" }
["end_date"]=> array(1) { [0]=> string(10) "02-02-2015" }
}
</code></pre>
<p>But I want it to be like this: </p>
<pre><code> array(8) {
["product_i... | [
{
"answer_id": 179193,
"author": "Abhisek Malakar",
"author_id": 62784,
"author_profile": "https://wordpress.stackexchange.com/users/62784",
"pm_score": 0,
"selected": false,
"text": "<p>THe only possible way is this if your html input name is</p>\n\n<p>name=\"end_date[]\"...</p>\n\n<p>S... | 2015/02/24 | [
"https://wordpress.stackexchange.com/questions/179167",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45567/"
] | So, this is how WordPress is saving my CPT meta:
```
array(8) {
["product_id"]=> array(1) { [0]=> string(10) "abcdefg987" }
["end_date"]=> array(1) { [0]=> string(10) "02-02-2015" }
}
```
But I want it to be like this:
```
array(8) {
["product_id"]=> "abcdefg987" ,
["end_date"]=> "02-02-2015"... | Your issue is not with storage, it is with retrieval. `get_post_custom()` is inconvenient and rarely used in practice.
[`get_post_meta()`](http://queryposts.com/function/get_post_meta/) is more common in practice. Note it has explicit argument to retrieve a single value, rather than array of values for a key (which WP... |
179,187 | <p>I am working on a custom carousel (Wordpress + Bootstrap). The carousel is working without problems. However, I would like to hide Bootstrap carousel indicators and arrows if there is only one post.</p>
<p>I was able to hide the carousel arrows by using this code:</p>
<pre><code><?php if ($counter > 1) { ?&g... | [
{
"answer_id": 179188,
"author": "Abhisek Malakar",
"author_id": 62784,
"author_profile": "https://wordpress.stackexchange.com/users/62784",
"pm_score": 2,
"selected": true,
"text": "<p>You can use the condition </p>\n\n<pre><code><?php\n if($loop->post_count > 1){\n /... | 2015/02/24 | [
"https://wordpress.stackexchange.com/questions/179187",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/21245/"
] | I am working on a custom carousel (Wordpress + Bootstrap). The carousel is working without problems. However, I would like to hide Bootstrap carousel indicators and arrows if there is only one post.
I was able to hide the carousel arrows by using this code:
```
<?php if ($counter > 1) { ?>
<a class="left carou... | You can use the condition
```
<?php
if($loop->post_count > 1){
/**
* so show the carousel counter
*/
}
?>
``` |
179,208 | <p>I have tried the following SQL query without any success. Can anybody that have a better understanding of SQL help?</p>
<p>Here is what I am trying to achieve:</p>
<ul>
<li>Get a list of all main events (ME) where the parent_id = 0.</li>
<li>Order the ME list based on the post date of the earliest child events whi... | [
{
"answer_id": 179226,
"author": "Kobus Beets",
"author_id": 63672,
"author_profile": "https://wordpress.stackexchange.com/users/63672",
"pm_score": 1,
"selected": false,
"text": "<p>After hours of searching and testing I finally came to a solution. This code and SQL shows events with a ... | 2015/02/24 | [
"https://wordpress.stackexchange.com/questions/179208",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63672/"
] | I have tried the following SQL query without any success. Can anybody that have a better understanding of SQL help?
Here is what I am trying to achieve:
* Get a list of all main events (ME) where the parent\_id = 0.
* Order the ME list based on the post date of the earliest child events which is obtained from a sub q... | The very thing I tried to accomplish appear not to be complex at all.
SQL Code:
```
SELECT *
FROM wp_posts
WHERE post_type = "event"
AND post_status IN ("publish", "future")
AND post_date > "2015-02-26"
AND post_parent != 0
GROUP BY post_parent
ORDER BY post_date ASC;
```
There were two ways... |
179,209 | <p>I tried to find filters or a hook to modify link returned by this function</p>
<p><a href="http://codex.wordpress.org/Function_Reference/get_post_type_archive_link" rel="nofollow"><code>get_post_type_archive_link()</code></a></p>
<p>I have gone through most of the documentation. I'm not sure it's not there or I'm ... | [
{
"answer_id": 179212,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 4,
"selected": true,
"text": "<p>The filter is <code>post_type_archive_link</code>, <a href=\"https://core.trac.wordpress.org/browser/tags/4.1.... | 2015/02/24 | [
"https://wordpress.stackexchange.com/questions/179209",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68069/"
] | I tried to find filters or a hook to modify link returned by this function
[`get_post_type_archive_link()`](http://codex.wordpress.org/Function_Reference/get_post_type_archive_link)
I have gone through most of the documentation. I'm not sure it's not there or I'm not able to find it.
Any suggestions would be very ap... | The filter is `post_type_archive_link`, [defined (WP 4.1.1) on line 1112 of file wp-includes/link-template.php](https://core.trac.wordpress.org/browser/tags/4.1.1/src/wp-includes/link-template.php#L1112):
```
apply_filters( 'post_type_archive_link', $link, $post_type );
```
And the use:
```
add_filter( 'post_type_a... |
179,263 | <p>I know that normal WP_Query's can have an <code>"orderby"</code> parameter of <code>"meta_value_num"</code>, but when I try to user <code>"orderby" => "meta_value_num"</code> on a WP_User_Query, it doesn't seem to work. Anyway I can obtain this functionality or is there something I'm missing?</p>
<p>Edit:</p>
<... | [
{
"answer_id": 179265,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": true,
"text": "<p>This is untested, but I believe if you set <code>type</code> in your meta query to <code>numeric</code>, that will ... | 2015/02/24 | [
"https://wordpress.stackexchange.com/questions/179263",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37660/"
] | I know that normal WP\_Query's can have an `"orderby"` parameter of `"meta_value_num"`, but when I try to user `"orderby" => "meta_value_num"` on a WP\_User\_Query, it doesn't seem to work. Anyway I can obtain this functionality or is there something I'm missing?
Edit:
Here's what I've tried to retrieve results order... | This is untested, but I believe if you set `type` in your meta query to `numeric`, that will cast the values as numbers so orderby `meta_value` should work correctly. |
179,279 | <p>Reading the <a href="https://make.wordpress.org/core/handbook/inline-documentation-standards/php-documentation-standards/" rel="nofollow">WordPress PHP Documentation Standards</a>, I can't see anywhere that mentions how to document a function call such as <code>add_action( 'foo', 'bar' );</code></p>
<p>Should I be ... | [
{
"answer_id": 179294,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 3,
"selected": true,
"text": "<p>You don't document function calls, but function definitions. Because the function could be called un... | 2015/02/24 | [
"https://wordpress.stackexchange.com/questions/179279",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22599/"
] | Reading the [WordPress PHP Documentation Standards](https://make.wordpress.org/core/handbook/inline-documentation-standards/php-documentation-standards/), I can't see anywhere that mentions how to document a function call such as `add_action( 'foo', 'bar' );`
Should I be documenting function calls and, if so, how? | You don't document function calls, but function definitions. Because the function could be called unlimited times, right? So it makes no sense to document functions when they are called.
If you document the call, then probably because you do some things you want to remember later - or let other following developers k... |
179,285 | <p>I have a table, where each post has a custom field with "region" and "city":</p>
<ul>
<li>01 > SP > São Paulo</li>
<li>02 > RJ > Rio de Janeiro</li>
<li>03 > SP > Campinas</li>
<li>04 > RJ > Niteroi</li>
</ul>
<p>This query is working perfect for showing all posts in "Region = SP":</p>
<pre><code>... | [
{
"answer_id": 179290,
"author": "Przemek Maczewski",
"author_id": 68013,
"author_profile": "https://wordpress.stackexchange.com/users/68013",
"pm_score": 0,
"selected": false,
"text": "<p>You might try this but using query_posts() is strongly discouraged:</p>\n\n<pre><code>query_posts(\... | 2015/02/24 | [
"https://wordpress.stackexchange.com/questions/179285",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44576/"
] | I have a table, where each post has a custom field with "region" and "city":
* 01 > SP > São Paulo
* 02 > RJ > Rio de Janeiro
* 03 > SP > Campinas
* 04 > RJ > Niteroi
This query is working perfect for showing all posts in "Region = SP":
```
query_posts( array(
'post_type' => 'hotel',
'post_per_page' =>... | Regions and cities fit perfectly in the concept of taxonomy: a way to group things (i.e. posts). And not so much in the concept of meta data. I strongly recommend to use custom taxonomies for that instead of custom meta fields. You will gain in performance and you will have a better data relationship management. Additi... |
179,330 | <p>I am using the following code to hide the teaser and show content only after more tag in loop:</p>
<pre><code><?php
$after_more = explode(
'<!--more-->',
$post->post_content
);
if( $after_more[1] ) {
echo $after_more[1];
} else {
echo $after_more[0];
}
?>
</code></pre>
<p>Is the... | [
{
"answer_id": 179324,
"author": "rootx",
"author_id": 68133,
"author_profile": "https://wordpress.stackexchange.com/users/68133",
"pm_score": -1,
"selected": false,
"text": "<p>Use site like wpthemedetector.com to detect which theme that site is using or visit that site and press ctrl+u... | 2015/02/25 | [
"https://wordpress.stackexchange.com/questions/179330",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13058/"
] | I am using the following code to hide the teaser and show content only after more tag in loop:
```
<?php
$after_more = explode(
'<!--more-->',
$post->post_content
);
if( $after_more[1] ) {
echo $after_more[1];
} else {
echo $after_more[0];
}
?>
```
Is there anyway to show only first 50 words ins... | In general it is impossible, and probably pointless as well. It is not enough to know which theme is being used but you will also need to know its configuration and then what about different versions, local changes or even server settings (ok, this probably only in rare cases).
The best way to know what theme is used ... |