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 |
|---|---|---|---|---|---|---|
151,364 | <p>I created a user form on my index page which allows the site visitor to re-order my post loop order based on either most recent posts or highest rated posts. The form works perfectly, the problem is: the post loop loads by most recent as a default, but after they select/submit for the highest rated order, the page r... | [
{
"answer_id": 151358,
"author": "Christoph Daum",
"author_id": 54549,
"author_profile": "https://wordpress.stackexchange.com/users/54549",
"pm_score": 1,
"selected": false,
"text": "<p>Have you checked the database? </p>\n\n<p>Especially \"wp-options\" and there the key \"siteurl\". </p... | 2014/06/21 | [
"https://wordpress.stackexchange.com/questions/151364",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54554/"
] | I created a user form on my index page which allows the site visitor to re-order my post loop order based on either most recent posts or highest rated posts. The form works perfectly, the problem is: the post loop loads by most recent as a default, but after they select/submit for the highest rated order, the page refr... | Have you checked the database?
Especially "wp-options" and there the key "siteurl".
Best would probably be to do a complete dump, search for <https://www.yourdomain.com> and replace it with <http://www.yourdomain.com> |
151,383 | <p>My blog posts have have multiple items from my custom taxonomy attached to them.
For the sake of this post lets just use Tags taxonomy...</p>
<p>So a post may contain 4 tags, is there a way I can select one tag as the primary tag for the post?</p>
| [
{
"answer_id": 151404,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": -1,
"selected": false,
"text": "<p>No, you cannot. Taxonomies, categories, and terms all carries the same rank in the hierarchy when they... | 2014/06/21 | [
"https://wordpress.stackexchange.com/questions/151383",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19527/"
] | My blog posts have have multiple items from my custom taxonomy attached to them.
For the sake of this post lets just use Tags taxonomy...
So a post may contain 4 tags, is there a way I can select one tag as the primary tag for the post? | This post is super old but I'll post my solution here in case anyone else stumbles across this.
If you're using Yoast SEO you can hook into their existing implementation (they do this already for categories).
```
function add_variety_primary_term_taxonomy( $taxonomies, $post_type, $all ) {
if( $post_type == 'prod... |
151,397 | <p>I'm creating a plugin for WooCommerce, it needs a parameter in the url of shop page like this <code>http://domain/wp/shop/?param=value</code>. It worked fine until I set the shop page as front page, when I access <code>http://domain/wp</code>, it is showing the shop page, but when I access it with the parameter (<co... | [
{
"answer_id": 151404,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": -1,
"selected": false,
"text": "<p>No, you cannot. Taxonomies, categories, and terms all carries the same rank in the hierarchy when they... | 2014/06/22 | [
"https://wordpress.stackexchange.com/questions/151397",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51554/"
] | I'm creating a plugin for WooCommerce, it needs a parameter in the url of shop page like this `http://domain/wp/shop/?param=value`. It worked fine until I set the shop page as front page, when I access `http://domain/wp`, it is showing the shop page, but when I access it with the parameter (`http://domain/wp/?param=val... | This post is super old but I'll post my solution here in case anyone else stumbles across this.
If you're using Yoast SEO you can hook into their existing implementation (they do this already for categories).
```
function add_variety_primary_term_taxonomy( $taxonomies, $post_type, $all ) {
if( $post_type == 'prod... |
151,406 | <p>sorry for the silly question, but I am really lost.
I want to apply the following CSS to the even elements of my foreach.</p>
<p><strong>CSS</strong></p>
<pre><code>.blogArticles a {
float: left;
max-width: 250px;
width: 25%;
color: #333;
}
.blogArticles a:nth-child(even) {
margin: 30px 0 -30p... | [
{
"answer_id": 151415,
"author": "Mark",
"author_id": 22715,
"author_profile": "https://wordpress.stackexchange.com/users/22715",
"pm_score": 0,
"selected": false,
"text": "<p>To fix the problem, I just removed the <code>$count = 0</code> before the <code>foreach()</code> and: </p>\n\n<p... | 2014/06/22 | [
"https://wordpress.stackexchange.com/questions/151406",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22715/"
] | sorry for the silly question, but I am really lost.
I want to apply the following CSS to the even elements of my foreach.
**CSS**
```
.blogArticles a {
float: left;
max-width: 250px;
width: 25%;
color: #333;
}
.blogArticles a:nth-child(even) {
margin: 30px 0 -30px 0;
}
```
**PHP** **UPDATED (I ... | Firstly, you should never use [`query_posts`](http://codex.wordpress.org/Function_Reference/query_posts) to construct custom queries. This is not just my emphasis, but the codex as well. The one big problem with `query_posts` is, it many circumstances, pagination fails
>
> **Note:** This function isn't meant to be us... |
151,418 | <p>I try to make a plugin that can show a table (with rows) in wordpress by using the <code>WP_List_Table</code> class.</p>
<p>In my "students" table Ive got</p>
<pre><code>Fname,Lname,school,Class
</code></pre>
<p>I've already found a example where they use arrays and typing manual everything to the table, which t... | [
{
"answer_id": 151425,
"author": "Sormano",
"author_id": 48607,
"author_profile": "https://wordpress.stackexchange.com/users/48607",
"pm_score": 1,
"selected": false,
"text": "<p>I think you should rethink if creating a custom <a href=\"http://codex.wordpress.org/Class_Reference/WP_List_... | 2014/06/22 | [
"https://wordpress.stackexchange.com/questions/151418",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54140/"
] | I try to make a plugin that can show a table (with rows) in wordpress by using the `WP_List_Table` class.
In my "students" table Ive got
```
Fname,Lname,school,Class
```
I've already found a example where they use arrays and typing manual everything to the table, which then looks like this
```
var $example_data = ... | I think you should rethink if creating a custom [wp\_list\_table](http://codex.wordpress.org/Class_Reference/WP_List_Table) & stuff is the way to go.
I can tell from experience wp\_list\_table isn't fun to work with.
Besides I think (as far as I can judge here) a [custom post type](http://codex.wordpress.org/Function... |
151,432 | <p>Currently I’m working on a WordPress plugin and as part of it users can upload Images. What I want to do is that these uploaded images of any size will be resized to 100px by 100px without cropping. </p>
<p>Here’s the part of the code where the resizing is done. It works but, but not without cropping. I hope someon... | [
{
"answer_id": 151425,
"author": "Sormano",
"author_id": 48607,
"author_profile": "https://wordpress.stackexchange.com/users/48607",
"pm_score": 1,
"selected": false,
"text": "<p>I think you should rethink if creating a custom <a href=\"http://codex.wordpress.org/Class_Reference/WP_List_... | 2014/06/22 | [
"https://wordpress.stackexchange.com/questions/151432",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54587/"
] | Currently I’m working on a WordPress plugin and as part of it users can upload Images. What I want to do is that these uploaded images of any size will be resized to 100px by 100px without cropping.
Here’s the part of the code where the resizing is done. It works but, but not without cropping. I hope someone can help... | I think you should rethink if creating a custom [wp\_list\_table](http://codex.wordpress.org/Class_Reference/WP_List_Table) & stuff is the way to go.
I can tell from experience wp\_list\_table isn't fun to work with.
Besides I think (as far as I can judge here) a [custom post type](http://codex.wordpress.org/Function... |
151,454 | <p>I have a theme where the developer used get_tempalate_part() a lot, and these parts are scattered across theme subdirectories as well as in directories in a plugin that was created to assist with the theme.</p>
<p>Here is the code I'm using to understand the primary template being called (the parent template, for l... | [
{
"answer_id": 151457,
"author": "Christoph Daum",
"author_id": 54549,
"author_profile": "https://wordpress.stackexchange.com/users/54549",
"pm_score": 0,
"selected": false,
"text": "<p>An easy way is to add some echo to each template file. Like <code><!--folder/filename.php--></co... | 2014/06/22 | [
"https://wordpress.stackexchange.com/questions/151454",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37934/"
] | I have a theme where the developer used get\_tempalate\_part() a lot, and these parts are scattered across theme subdirectories as well as in directories in a plugin that was created to assist with the theme.
Here is the code I'm using to understand the primary template being called (the parent template, for lack of b... | You can view the template part by using [`get_template_part($slug)`](http://codex.wordpress.org/Function_Reference/get_template_part)
It’s one of those hidden gems inside of WordPress that don’t get the attention they deserve.
The `get_template_part` function is essentially a PHP include or require, on steroids:
>
> ... |
151,497 | <p>Is there a way to show a PDF file inside Post in Wordpress?
I used the tag but if someone has Internet Download Manager the Dialog will appear to Download the PDF file and then if they click cancel they will not be able to see it, they can ONLY download it</p>
<p>Is there's a way to stop automatic download?</p>
<p>... | [
{
"answer_id": 151539,
"author": "Troy Templeman",
"author_id": 40536,
"author_profile": "https://wordpress.stackexchange.com/users/40536",
"pm_score": 0,
"selected": false,
"text": "<p>The <a href=\"https://wordpress.org/plugins/dirtysuds-embed-pdf/\" rel=\"nofollow\">Embed PDF Plugin</... | 2014/06/23 | [
"https://wordpress.stackexchange.com/questions/151497",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54070/"
] | Is there a way to show a PDF file inside Post in Wordpress?
I used the tag but if someone has Internet Download Manager the Dialog will appear to Download the PDF file and then if they click cancel they will not be able to see it, they can ONLY download it
Is there's a way to stop automatic download?
There are many p... | The only reliable cross browser solution is to embed the .pdf in a `iframe`.
```
add_filter('media_send_to_editor', 'my_pdf_embed', 20, 3);
function my_pdf_embed($html, $id) {
$attachment = get_post($id); //fetching attachment by $id passed through
$mime_type = $attachment->post_mime_type; //getting the mime... |
151,504 | <p>I'm trying to write an action that will modify some WooCommerce product on its display.</p>
<p>This is my simple code</p>
<pre><code>function do_some_modifications($post)
{
if (is_singular('product')) {
// do some action
}
return $post;
}
add_action('the_post', 'do_some_modifications');
</code>... | [
{
"answer_id": 151508,
"author": "Vasu Chawla",
"author_id": 40625,
"author_profile": "https://wordpress.stackexchange.com/users/40625",
"pm_score": 0,
"selected": false,
"text": "<p>replace </p>\n\n<pre><code> if (is_singular('product')){\n // do some action\n }\n</code></pr... | 2014/06/23 | [
"https://wordpress.stackexchange.com/questions/151504",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54613/"
] | I'm trying to write an action that will modify some WooCommerce product on its display.
This is my simple code
```
function do_some_modifications($post)
{
if (is_singular('product')) {
// do some action
}
return $post;
}
add_action('the_post', 'do_some_modifications');
```
But the page contains ... | Okay. Here we go!
I needed this to be implemented within only one plugin, not inside the template.
So I found out how to get the ID of current post outside the loop.
The great function [get\_queried\_object()](http://codex.wordpress.org/Function_Reference/get_queried_object) and [get\_queried\_object\_id()](http://co... |
151,525 | <p>In the site I'm building there is a post-type called "Focus". Since they need to url to be like <code>www.mysite.com/focus/page-post-name</code> I have the post type slug as "focus".</p>
<p>Of course the archive page is <code>www.mysite.com/focus</code> this is causing an issue since I need a specific page to be an... | [
{
"answer_id": 151531,
"author": "Tim McClure",
"author_id": 36167,
"author_profile": "https://wordpress.stackexchange.com/users/36167",
"pm_score": 0,
"selected": false,
"text": "<p>If I'm understanding right, you have a post type that uses the /focus slug, but you want a normal page ca... | 2014/06/23 | [
"https://wordpress.stackexchange.com/questions/151525",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8278/"
] | In the site I'm building there is a post-type called "Focus". Since they need to url to be like `www.mysite.com/focus/page-post-name` I have the post type slug as "focus".
Of course the archive page is `www.mysite.com/focus` this is causing an issue since I need a specific page to be an archive page. Meta boxes are us... | You can add the following to your `.htaccess` file in between the `<IfModule mod_rewrite.c>` tags:
```
RewriteCond %{HTTP_HOST}
RewriteRule ^our-focus/(.*)$ /focus/$1 [R=301,L]
```
Your `.htaccess` should looks like the following:
```
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
Rewrite... |
151,554 | <p>So Im using the <code>tiny_mce_before_init</code> filter to added a few classes to the <code>wp_editor</code> and am getting unexpected results. I havent used this before, but from what Im reading and what my peers tell me I should be able to apply classes to elements in the editor directly, and not creating a wrapp... | [
{
"answer_id": 151531,
"author": "Tim McClure",
"author_id": 36167,
"author_profile": "https://wordpress.stackexchange.com/users/36167",
"pm_score": 0,
"selected": false,
"text": "<p>If I'm understanding right, you have a post type that uses the /focus slug, but you want a normal page ca... | 2014/06/23 | [
"https://wordpress.stackexchange.com/questions/151554",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19536/"
] | So Im using the `tiny_mce_before_init` filter to added a few classes to the `wp_editor` and am getting unexpected results. I havent used this before, but from what Im reading and what my peers tell me I should be able to apply classes to elements in the editor directly, and not creating a wrapper element.
So I have t... | You can add the following to your `.htaccess` file in between the `<IfModule mod_rewrite.c>` tags:
```
RewriteCond %{HTTP_HOST}
RewriteRule ^our-focus/(.*)$ /focus/$1 [R=301,L]
```
Your `.htaccess` should looks like the following:
```
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
Rewrite... |
151,587 | <p>I am inserting a row into a custom table in a wordpress database. this is the code:</p>
<pre><code>$wpdb->insert( 'wp_pl_my_parts',
array(
'user_ID' => $user_ID,
'PL_part_ID' => $PL_part_ID,
'part_save_date' => $part_sav... | [
{
"answer_id": 151592,
"author": "Caleuanhopkins",
"author_id": 24675,
"author_profile": "https://wordpress.stackexchange.com/users/24675",
"pm_score": 2,
"selected": false,
"text": "<p>I have found the best way to check it a record exists or not with WPDB is to check using the WPDB upda... | 2014/06/24 | [
"https://wordpress.stackexchange.com/questions/151587",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54475/"
] | I am inserting a row into a custom table in a wordpress database. this is the code:
```
$wpdb->insert( 'wp_pl_my_parts',
array(
'user_ID' => $user_ID,
'PL_part_ID' => $PL_part_ID,
'part_save_date' => $part_save_date ), array( '%d', '%d... | Let's say the primary key of the table is `my_part_ID`. So we will check if there is any primary key value for the combination of `user_ID` and `PL_part_ID` as below
```
$my_part_ID = $wpdb->get_var(
$wpdb->prepare(
"SELECT my_part_ID FROM " . $wpdb->prefix . "pl_my_parts
... |
151,589 | <p>To be specific:</p>
<ul>
<li>I'm using Masonry to show all posts within a certain category</li>
<li>Thumbnail images for each post are shown on the category page in a 3-column format using CSS fluid width columns</li>
<li>I need to show the 7th thumbnail image spanning the width of all 3 columns</li>
</ul>
<p>In t... | [
{
"answer_id": 151610,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 1,
"selected": false,
"text": "<p>This shouldn't be a problem with Masonry, at least I never had one with it (or its similar equivale... | 2014/06/24 | [
"https://wordpress.stackexchange.com/questions/151589",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52204/"
] | To be specific:
* I'm using Masonry to show all posts within a certain category
* Thumbnail images for each post are shown on the category page in a 3-column format using CSS fluid width columns
* I need to show the 7th thumbnail image spanning the width of all 3 columns
In the past I've added a counter to posts to t... | So I couldn't figure out how to add a number sequence class to each post/article div, but I just changed the template for the 7th post in the masonry template.
I did it like this:
```
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while (have_posts()) : the_post(); ?>
<?php $count++; ?>
<?php if ... |
151,598 | <p>What's the best way to send a email from Wordpress after a certain action.</p>
<p>I'm working on a site where users can submit ideas and then other users can comment on them.</p>
<p>I would like to send emails to a number of different addresses (moderators) when a post is made and when a comment is made.</p>
<p>I... | [
{
"answer_id": 151610,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 1,
"selected": false,
"text": "<p>This shouldn't be a problem with Masonry, at least I never had one with it (or its similar equivale... | 2014/06/24 | [
"https://wordpress.stackexchange.com/questions/151598",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51590/"
] | What's the best way to send a email from Wordpress after a certain action.
I'm working on a site where users can submit ideas and then other users can comment on them.
I would like to send emails to a number of different addresses (moderators) when a post is made and when a comment is made.
I have this code to add t... | So I couldn't figure out how to add a number sequence class to each post/article div, but I just changed the template for the 7th post in the masonry template.
I did it like this:
```
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while (have_posts()) : the_post(); ?>
<?php $count++; ?>
<?php if ... |
151,616 | <p>So i've been googling around and i'm trying to figure out a plain simple solution to my problem. I've tried several things but they are simply not working. I just got into WordPress and i have to edit some permissions. I want to give the Editor rank access to ONE specific plugin. I've determined that this is the pie... | [
{
"answer_id": 151610,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 1,
"selected": false,
"text": "<p>This shouldn't be a problem with Masonry, at least I never had one with it (or its similar equivale... | 2014/06/24 | [
"https://wordpress.stackexchange.com/questions/151616",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54667/"
] | So i've been googling around and i'm trying to figure out a plain simple solution to my problem. I've tried several things but they are simply not working. I just got into WordPress and i have to edit some permissions. I want to give the Editor rank access to ONE specific plugin. I've determined that this is the piece ... | So I couldn't figure out how to add a number sequence class to each post/article div, but I just changed the template for the 7th post in the masonry template.
I did it like this:
```
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while (have_posts()) : the_post(); ?>
<?php $count++; ?>
<?php if ... |
151,617 | <p>It's now several hours that I am trying to get this done without finding a proper solution.</p>
<p><strong>WHAT I WANT TO ACHIEVE</strong></p>
<p>I'd like WP to use the following URL structure: </p>
<pre><code>1) Posts -> /%category%/articles/%postname%/
2) CPT -> /%category%/CPT/%postname%/
</code></pre>... | [
{
"answer_id": 151651,
"author": "Caleuanhopkins",
"author_id": 24675,
"author_profile": "https://wordpress.stackexchange.com/users/24675",
"pm_score": 0,
"selected": false,
"text": "<p><code>/%category%/</code> isn't a variable that Wordpress can process or replace when you setup a slug... | 2014/06/24 | [
"https://wordpress.stackexchange.com/questions/151617",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26216/"
] | It's now several hours that I am trying to get this done without finding a proper solution.
**WHAT I WANT TO ACHIEVE**
I'd like WP to use the following URL structure:
```
1) Posts -> /%category%/articles/%postname%/
2) CPT -> /%category%/CPT/%postname%/
```
Where the %category% bit is the default categories tax... | You'll have to add your own rewrite rules to make this work, no way around that.
First, don't use the `%category%` rewrite tag, register your own tag and use that for the CPT categories:
```
function wpd_query_vars( $qvars ) {
$qvars[] = 'cptcat';
return $qvars;
}
add_filter( 'query_vars', 'wpd_query_vars' );... |
151,631 | <p>I'm sure this isn't possible but I thought I would ask.</p>
<p>In my functions.php file I have a wp_mail function that sends an email to moderators when posts are made.</p>
<p>This email is sent to number of different address - these addresses might change.</p>
<p>I thought it would easier to set these email addr... | [
{
"answer_id": 151651,
"author": "Caleuanhopkins",
"author_id": 24675,
"author_profile": "https://wordpress.stackexchange.com/users/24675",
"pm_score": 0,
"selected": false,
"text": "<p><code>/%category%/</code> isn't a variable that Wordpress can process or replace when you setup a slug... | 2014/06/24 | [
"https://wordpress.stackexchange.com/questions/151631",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51590/"
] | I'm sure this isn't possible but I thought I would ask.
In my functions.php file I have a wp\_mail function that sends an email to moderators when posts are made.
This email is sent to number of different address - these addresses might change.
I thought it would easier to set these email addresses in the WP Dashboa... | You'll have to add your own rewrite rules to make this work, no way around that.
First, don't use the `%category%` rewrite tag, register your own tag and use that for the CPT categories:
```
function wpd_query_vars( $qvars ) {
$qvars[] = 'cptcat';
return $qvars;
}
add_filter( 'query_vars', 'wpd_query_vars' );... |
151,636 | <p>I'm trying to reference posts to each other. Editors should have a custom field select list of certain post's titles to link the current post with other posts. I got quite far, I think. The select list appears correctly. All titles are there.</p>
<p>Now, I'm stuck at the point, where the referred post's ID has to b... | [
{
"answer_id": 151652,
"author": "leymannx",
"author_id": 30597,
"author_profile": "https://wordpress.stackexchange.com/users/30597",
"pm_score": 3,
"selected": true,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/selected\" rel=\"nofollow noreferrer\"><code>selected... | 2014/06/24 | [
"https://wordpress.stackexchange.com/questions/151636",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30597/"
] | I'm trying to reference posts to each other. Editors should have a custom field select list of certain post's titles to link the current post with other posts. I got quite far, I think. The select list appears correctly. All titles are there.
Now, I'm stuck at the point, where the referred post's ID has to be saved.
... | [`selected()`](http://codex.wordpress.org/Function_Reference/selected) was big help for setting a default value. The rest I found in this brilliant meta box tutorial: <http://code.tutsplus.com/tutorials/how-to-create-custom-wordpress-writemeta-boxes--wp-20336> with examples for text input, checkboxes and dropdown. Also... |
151,656 | <p>I want to manipulate the html-title tag, so <code><title></code> these not the content of the title-tag!</p>
<p>I use child-themes and it's inevitable, because the template have to be easy to update.
So I have to use the functions.php or the header.php in the child-folder.</p>
<p>At moment I try it with the... | [
{
"answer_id": 151815,
"author": "eyoung100",
"author_id": 51113,
"author_profile": "https://wordpress.stackexchange.com/users/51113",
"pm_score": 0,
"selected": false,
"text": "<p>I still don't know why you're trying to pass the item property through the head tag. I have a gut feeling ... | 2014/06/24 | [
"https://wordpress.stackexchange.com/questions/151656",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54686/"
] | I want to manipulate the html-title tag, so `<title>` these not the content of the title-tag!
I use child-themes and it's inevitable, because the template have to be easy to update.
So I have to use the functions.php or the header.php in the child-folder.
At moment I try it with the functions.php
At moment I have f... | I don't think adding `<span itemprop>` to the `<title>` is a good idea... If you can not use any existing tags like `<h1>` for that, you may consider adding `meta` tag: `<meta itemprop="name" content="Company Name">`. You can add this using wp\_head, but keep in mind it should be within `itemscope`.
If you really goin... |
151,669 | <p>Googled this for hours, cannot find a solution.</p>
<p>On my <a href="http://www.elevancement.com/themes/browse/" rel="nofollow">theme</a> you have a <code>Browse</code> page which pulls all the videos from the Custom Post Type I am working with. If a user makes 30 categories then id like for users to be able to so... | [
{
"answer_id": 151815,
"author": "eyoung100",
"author_id": 51113,
"author_profile": "https://wordpress.stackexchange.com/users/51113",
"pm_score": 0,
"selected": false,
"text": "<p>I still don't know why you're trying to pass the item property through the head tag. I have a gut feeling ... | 2014/06/24 | [
"https://wordpress.stackexchange.com/questions/151669",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52719/"
] | Googled this for hours, cannot find a solution.
On my [theme](http://www.elevancement.com/themes/browse/) you have a `Browse` page which pulls all the videos from the Custom Post Type I am working with. If a user makes 30 categories then id like for users to be able to sort the videos using the Category buttons listed... | I don't think adding `<span itemprop>` to the `<title>` is a good idea... If you can not use any existing tags like `<h1>` for that, you may consider adding `meta` tag: `<meta itemprop="name" content="Company Name">`. You can add this using wp\_head, but keep in mind it should be within `itemscope`.
If you really goin... |
151,695 | <p>I'm using the Divi theme to build my website.My client wants News and Blog page on the same site, so I did this by using categories. </p>
<p>My problem is how to achieve category(i.e News and Blog) specific sidebars? By default, posts uses the default sidebars. I set the default sidebar to my Blog page.</p>
<p>I'v... | [
{
"answer_id": 151706,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 1,
"selected": false,
"text": "<p>Create a <a href=\"http://codex.wordpress.org/Child_Themes\" rel=\"nofollow\">child theme</a> (if you have... | 2014/06/25 | [
"https://wordpress.stackexchange.com/questions/151695",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54710/"
] | I'm using the Divi theme to build my website.My client wants News and Blog page on the same site, so I did this by using categories.
My problem is how to achieve category(i.e News and Blog) specific sidebars? By default, posts uses the default sidebars. I set the default sidebar to my Blog page.
I've installed the w... | Create a [child theme](http://codex.wordpress.org/Child_Themes) (if you haven't already) and [register two sidebars](http://codex.wordpress.org/Function_Reference/register_sidebar):
```
function wpse_151695_register_sidebars() {
register_sidebar(
array(
'name' => 'News',
'id' => '... |
151,696 | <p>I have registered several sidebars via functions.php like this: </p>
<pre><code>// Register sidebars
function register_widgets() {
// Main sidebar
register_sidebar( array(
'name' => __( 'Main Sidebar', 'Core' ),
'id' => 'main',
'description' => __( 'The main sidebar appears on the right on e... | [
{
"answer_id": 151697,
"author": "Matt Royal",
"author_id": 51860,
"author_profile": "https://wordpress.stackexchange.com/users/51860",
"pm_score": 0,
"selected": false,
"text": "<p>Why not use the WordPress function <code>locate_template()</code>. Information on it in the WordPress Code... | 2014/06/25 | [
"https://wordpress.stackexchange.com/questions/151696",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37548/"
] | I have registered several sidebars via functions.php like this:
```
// Register sidebars
function register_widgets() {
// Main sidebar
register_sidebar( array(
'name' => __( 'Main Sidebar', 'Core' ),
'id' => 'main',
'description' => __( 'The main sidebar appears on the right on each page except the fro... | You've made a mistake in your widgets.php file, most probably forgetting to add an opening `</php` tag at the start of your file. Also, I forgot one more thing, `require_once("includes/widgets.php");` should not be in any function or hook
Just for the sake of interes, you can cut down on code if you register many side... |
151,699 | <p>I have 15 categories. I list this using <code><div class="category_list"><ul><li><?php wp_list_categories();?></li></ul></div></code>
Now it's listing all 15 categories into a single div which is category_list.</p>
<p>I am trying to print these categories 5 by 5 in three di... | [
{
"answer_id": 151701,
"author": "Win More",
"author_id": 45710,
"author_profile": "https://wordpress.stackexchange.com/users/45710",
"pm_score": 2,
"selected": false,
"text": "<p>You can use <a href=\"http://codex.wordpress.org/Function_Reference/get_categories\" rel=\"nofollow\">get_ca... | 2014/06/25 | [
"https://wordpress.stackexchange.com/questions/151699",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43764/"
] | I have 15 categories. I list this using `<div class="category_list"><ul><li><?php wp_list_categories();?></li></ul></div>`
Now it's listing all 15 categories into a single div which is category\_list.
I am trying to print these categories 5 by 5 in three divs. like:
`<div class="category_list">first 5 categories here... | You can use [get\_categories()](http://codex.wordpress.org/Function_Reference/get_categories) function.
```
<?php
$cats = get_categories();
$count = 15; // Total Categorie
$linetotal=round($count/3); ?> // Part of Categorie
<div class="category_list">
<ul><?php
$totalcount = 1;
$totalpart =... |
151,723 | <p>I don’t need Yoast SEO meta box for one post type so I removed it with remove_meta_box(). Removed unneeded columns in post table by unsetting columns with manage_edit-custom_post_columns, but drop down is still left. Is there way to remove it?</p>
<p>Of course it is not that hard to do with jQuery, but maybe there ... | [
{
"answer_id": 151727,
"author": "engelen",
"author_id": 40403,
"author_profile": "https://wordpress.stackexchange.com/users/40403",
"pm_score": 4,
"selected": true,
"text": "<p>These additional dropdowns are added via the <code>restrict_manage_posts</code> action hook. This means the dr... | 2014/06/25 | [
"https://wordpress.stackexchange.com/questions/151723",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54388/"
] | I don’t need Yoast SEO meta box for one post type so I removed it with remove\_meta\_box(). Removed unneeded columns in post table by unsetting columns with manage\_edit-custom\_post\_columns, but drop down is still left. Is there way to remove it?
Of course it is not that hard to do with jQuery, but maybe there is fi... | These additional dropdowns are added via the `restrict_manage_posts` action hook. This means the dropdown output isn't filterable, but you can remove the hooked action from Yoast SEO.
The filter dropdown is added by the `posts_filter_dropdown()` method in the `WPSEO_Metabox` class. It's added in the `setup_page_analys... |
151,736 | <p>I have a Wordpress database with three categories:</p>
<p>ID 3 : Europe
<br />
ID 4 : France (child of 3)
<br />
ID 5 : Paris (child of 4)</p>
<p>I now need to display all posts under their respective category, like this:</p>
<p><b>EUROPE</b>
<br />
Post 1
<br />
Post 2
<br />
Post 3</p>
<p></p></p>
<p><b>FRANC... | [
{
"answer_id": 151727,
"author": "engelen",
"author_id": 40403,
"author_profile": "https://wordpress.stackexchange.com/users/40403",
"pm_score": 4,
"selected": true,
"text": "<p>These additional dropdowns are added via the <code>restrict_manage_posts</code> action hook. This means the dr... | 2014/06/25 | [
"https://wordpress.stackexchange.com/questions/151736",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54733/"
] | I have a Wordpress database with three categories:
ID 3 : Europe
ID 4 : France (child of 3)
ID 5 : Paris (child of 4)
I now need to display all posts under their respective category, like this:
**EUROPE**
Post 1
Post 2
Post 3
**FRANCE**
Post 1
Post 3
**PARIS**
Post 3
* Post 1 was published under France
* ... | These additional dropdowns are added via the `restrict_manage_posts` action hook. This means the dropdown output isn't filterable, but you can remove the hooked action from Yoast SEO.
The filter dropdown is added by the `posts_filter_dropdown()` method in the `WPSEO_Metabox` class. It's added in the `setup_page_analys... |
151,753 | <p>I'm using the following code to display the featured image, post_title and custom field data from relevant child pages.</p>
<pre><code><?
$child_pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = ".$post->ID." AND post_type = 'page' ORDER BY 'title ASC' ", 'OBJECT');
if ( $child... | [
{
"answer_id": 151755,
"author": "engelen",
"author_id": 40403,
"author_profile": "https://wordpress.stackexchange.com/users/40403",
"pm_score": 2,
"selected": false,
"text": "<p>Unless there's a very good (usually performance, or, of course, inability of core functions to do what you ne... | 2014/06/25 | [
"https://wordpress.stackexchange.com/questions/151753",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52548/"
] | I'm using the following code to display the featured image, post\_title and custom field data from relevant child pages.
```
<?
$child_pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = ".$post->ID." AND post_type = 'page' ORDER BY 'title ASC' ", 'OBJECT');
if ( $child_pages ) :
foreach ( ... | You're using a raw SQL query to do a post query, this is bad, because:
* There are already APIs that do this
* It is no longer inheriting the default parameters
* It doesn't go through the caching system so it can be slower
Intead, use `WP_Query`.
The reason you're getting trashed posts is because you're not specify... |
151,760 | <p>Maybe I'm going about this the wrong way but this is my scenario... I would like to use WordPress as a CMS rather than a blogging platform. I have a website that will have somewhere between 25-50 pages and will not have any posts.</p>
<p>I'm looking to develop my own theme which should be fairly easy, however I'm g... | [
{
"answer_id": 151761,
"author": "Gioia Fueter",
"author_id": 51884,
"author_profile": "https://wordpress.stackexchange.com/users/51884",
"pm_score": 2,
"selected": false,
"text": "<p>Strictly, you don't need to use a loop in a page template, but it doesn't hurt, the content of the page ... | 2014/06/25 | [
"https://wordpress.stackexchange.com/questions/151760",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45051/"
] | Maybe I'm going about this the wrong way but this is my scenario... I would like to use WordPress as a CMS rather than a blogging platform. I have a website that will have somewhere between 25-50 pages and will not have any posts.
I'm looking to develop my own theme which should be fairly easy, however I'm getting a l... | Strictly, you don't need to use a loop in a page template, but it doesn't hurt, the content of the page will still load, the loop will simply only run once as there is only one post/page. Many themes include a loop in page templates, I guess for some compability issue.
If you are building your page template from scra... |
151,777 | <p>I would like to remove some ugly looking arrows that are standard on cart buttons in WooCommerce. To achieve this, I found a tip of adding the following code, which should remove the arrows when the document has loaded.</p>
<p>I assume I am going to put it in my functions.php? How exactly would I do that?</p>
<pre... | [
{
"answer_id": 151793,
"author": "Matt Royal",
"author_id": 51860,
"author_profile": "https://wordpress.stackexchange.com/users/51860",
"pm_score": 3,
"selected": false,
"text": "<p>I would not add another external js file, its just an extra and unnecessary resource to fetch and that is ... | 2014/06/25 | [
"https://wordpress.stackexchange.com/questions/151777",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54742/"
] | I would like to remove some ugly looking arrows that are standard on cart buttons in WooCommerce. To achieve this, I found a tip of adding the following code, which should remove the arrows when the document has loaded.
I assume I am going to put it in my functions.php? How exactly would I do that?
```
$(document).re... | Your `$scr` in your [`wp_register_script()`](http://codex.wordpress.org/Function_Reference/wp_register_script) function is wrong. Given that your functions.php is inside your plugin, and your removeArrows.js is in the root of your plugin, your `$scr` should look like this
```
plugins_url( '/removeArrows.js' , __FILE__... |
151,788 | <p>Ok I have searched and can't find. Here is what I'm trying to accomplish. </p>
<p>I want to separate the tags in my post. For example, I want to show the first tag in my post but have all other tags show when you hover over the more button. Now the css and the menu I can handle, but how do I get the tags to separat... | [
{
"answer_id": 151793,
"author": "Matt Royal",
"author_id": 51860,
"author_profile": "https://wordpress.stackexchange.com/users/51860",
"pm_score": 3,
"selected": false,
"text": "<p>I would not add another external js file, its just an extra and unnecessary resource to fetch and that is ... | 2014/06/25 | [
"https://wordpress.stackexchange.com/questions/151788",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32447/"
] | Ok I have searched and can't find. Here is what I'm trying to accomplish.
I want to separate the tags in my post. For example, I want to show the first tag in my post but have all other tags show when you hover over the more button. Now the css and the menu I can handle, but how do I get the tags to separate, like pl... | Your `$scr` in your [`wp_register_script()`](http://codex.wordpress.org/Function_Reference/wp_register_script) function is wrong. Given that your functions.php is inside your plugin, and your removeArrows.js is in the root of your plugin, your `$scr` should look like this
```
plugins_url( '/removeArrows.js' , __FILE__... |
151,808 | <p>Trying to show the latest post with a <code>featured</code> tag. The query is working fine but it always shows all the content.. not the content before the more link which is all I want.</p>
<p>Here is my code.</p>
<pre><code>$query = new WP_Query('numberposts=1&orderby=date&tag=featured');
// The loop!
i... | [
{
"answer_id": 151793,
"author": "Matt Royal",
"author_id": 51860,
"author_profile": "https://wordpress.stackexchange.com/users/51860",
"pm_score": 3,
"selected": false,
"text": "<p>I would not add another external js file, its just an extra and unnecessary resource to fetch and that is ... | 2014/06/26 | [
"https://wordpress.stackexchange.com/questions/151808",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6694/"
] | Trying to show the latest post with a `featured` tag. The query is working fine but it always shows all the content.. not the content before the more link which is all I want.
Here is my code.
```
$query = new WP_Query('numberposts=1&orderby=date&tag=featured');
// The loop!
if ( $query->have_posts() ) : while ( $qu... | Your `$scr` in your [`wp_register_script()`](http://codex.wordpress.org/Function_Reference/wp_register_script) function is wrong. Given that your functions.php is inside your plugin, and your removeArrows.js is in the root of your plugin, your `$scr` should look like this
```
plugins_url( '/removeArrows.js' , __FILE__... |
151,821 | <p>I want to run one sql query like this in wordpress. Just wanted to know if there is an easy way to do this in wp. Thanks.</p>
<p>Is this query possible with the use of query_posts anyhow?</p>
<p><code>
select p1.meta_value as <code>avg</code>,p2.meta_value as total,p1.meta_value*p2.meta_value as product from wp_po... | [
{
"answer_id": 151825,
"author": "Adam",
"author_id": 54761,
"author_profile": "https://wordpress.stackexchange.com/users/54761",
"pm_score": 0,
"selected": false,
"text": "<p>Since I don't have enough points to comment, I'll just make this an answer.</p>\n\n<p>What are you trying to use... | 2014/06/26 | [
"https://wordpress.stackexchange.com/questions/151821",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45046/"
] | I want to run one sql query like this in wordpress. Just wanted to know if there is an easy way to do this in wp. Thanks.
Is this query possible with the use of query\_posts anyhow?
`select p1.meta_value as `avg`,p2.meta_value as total,p1.meta_value*p2.meta_value as product from wp_postmeta as p1, wp_postmeta as p2 w... | I wouldn't say it's "easy", but any complex queries like the one you have that can't be handled via the API, [`WP_Query`](http://codex.wordpress.org/Class_Reference/WP_Query), or its filters should use the [wpdb class](http://codex.wordpress.org/Class_Reference/wpdb).
```
global $wpdb;
$rows = $wpdb->get_results(
... |
151,849 | <p>I have used this technique before and cannot work out why this time it is not working.</p>
<p>'news_category' is a custom taxonomy of my custom post type 'News'.</p>
<p>I am getting the taxonomy of the current post (which is custom post type 'news') using get_the_term_list, replacing the spaces with '-' and using th... | [
{
"answer_id": 151825,
"author": "Adam",
"author_id": 54761,
"author_profile": "https://wordpress.stackexchange.com/users/54761",
"pm_score": 0,
"selected": false,
"text": "<p>Since I don't have enough points to comment, I'll just make this an answer.</p>\n\n<p>What are you trying to use... | 2014/06/26 | [
"https://wordpress.stackexchange.com/questions/151849",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/104926/"
] | I have used this technique before and cannot work out why this time it is not working.
'news\_category' is a custom taxonomy of my custom post type 'News'.
I am getting the taxonomy of the current post (which is custom post type 'news') using get\_the\_term\_list, replacing the spaces with '-' and using the variable ... | I wouldn't say it's "easy", but any complex queries like the one you have that can't be handled via the API, [`WP_Query`](http://codex.wordpress.org/Class_Reference/WP_Query), or its filters should use the [wpdb class](http://codex.wordpress.org/Class_Reference/wpdb).
```
global $wpdb;
$rows = $wpdb->get_results(
... |
151,850 | <p>I'm using a <a href="http://codex.wordpress.org/Custom_Headers" rel="noreferrer">custom header</a> in my theme. My aim is to add an <code>alt</code> attribute to my custom header <code>img</code> element. My <code>img</code> element so far looks like this:</p>
<pre><code><img src="<?php header_image(); ?>"... | [
{
"answer_id": 151864,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 4,
"selected": true,
"text": "<pre><code>/**\n * Get custom header's alt data.\n * \n * @link http://wordpress.stackexchange.com/q/151850... | 2014/06/26 | [
"https://wordpress.stackexchange.com/questions/151850",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22599/"
] | I'm using a [custom header](http://codex.wordpress.org/Custom_Headers) in my theme. My aim is to add an `alt` attribute to my custom header `img` element. My `img` element so far looks like this:
```
<img src="<?php header_image(); ?>" height="<?php echo get_custom_header()->height; ?>" width="<?php echo get_custom_he... | ```
/**
* Get custom header's alt data.
*
* @link http://wordpress.stackexchange.com/q/151850/1685
*
* @return string
*/
function wpse_151850_get_header_image_alt() {
$attachment_id = 0;
if ( is_random_header_image() && $header_url = get_header_image() ) {
// For a random header, we have to... |
151,852 | <p>I would like to create a shortcode that displays the last 3 posts to any page....</p>
<p>It should be laid out like this</p>
<blockquote>
<p>Title</p>
<p>Excerpt...Read more</p>
</blockquote>
<p>I've added this code in function.php</p>
<pre><code>function my_recent_post()
{
global $post;
$html = "";
... | [
{
"answer_id": 151859,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 3,
"selected": true,
"text": "<p>Add <a href=\"http://codex.wordpress.org/Function_Reference/wp_reset_postdata\" rel=\"nofollow\"><code>wp_r... | 2014/06/26 | [
"https://wordpress.stackexchange.com/questions/151852",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54779/"
] | I would like to create a shortcode that displays the last 3 posts to any page....
It should be laid out like this
>
> Title
>
>
> Excerpt...Read more
>
>
>
I've added this code in function.php
```
function my_recent_post()
{
global $post;
$html = "";
$my_query = new WP_Query( array(
'post_type... | Add [`wp_reset_postdata()`](http://codex.wordpress.org/Function_Reference/wp_reset_postdata) after your `while` loop:
```
endwhile;
wp_reset_postdata();
endif;
```
This will ensure that, after your shortcode runs, the *actual* current post is restored, so that any template tags display the right data. |
151,861 | <p>I've created a <a href="http://health.gov.ie/policy/" rel="nofollow">custom template</a> for a client. This is going to be a multilingual site setup on a Multisite install.</p>
<p>As you can see under each category letter, the posts start out in alphabetical order but "M" and "O" are all out of whack.</p>
<p>If yo... | [
{
"answer_id": 151859,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 3,
"selected": true,
"text": "<p>Add <a href=\"http://codex.wordpress.org/Function_Reference/wp_reset_postdata\" rel=\"nofollow\"><code>wp_r... | 2014/06/26 | [
"https://wordpress.stackexchange.com/questions/151861",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49135/"
] | I've created a [custom template](http://health.gov.ie/policy/) for a client. This is going to be a multilingual site setup on a Multisite install.
As you can see under each category letter, the posts start out in alphabetical order but "M" and "O" are all out of whack.
If you click through onto those categories, usin... | Add [`wp_reset_postdata()`](http://codex.wordpress.org/Function_Reference/wp_reset_postdata) after your `while` loop:
```
endwhile;
wp_reset_postdata();
endif;
```
This will ensure that, after your shortcode runs, the *actual* current post is restored, so that any template tags display the right data. |
151,874 | <p>I am new to wordpress so i am facing a problem in removing /category/ from wordpress URL</p>
<pre><code>http://domain/category/category-name
</code></pre>
<p>So i would like to know how to remove /category/ from the url. I have tried various solutions like </p>
<pre><code>Go to Settings >> Permalinks and s... | [
{
"answer_id": 151884,
"author": "evonline",
"author_id": 54789,
"author_profile": "https://wordpress.stackexchange.com/users/54789",
"pm_score": 0,
"selected": false,
"text": "<p>I recommend one of these two plugins to get the job done</p>\n\n<ul>\n<li><a href=\"https://wordpress.org/pl... | 2014/06/26 | [
"https://wordpress.stackexchange.com/questions/151874",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54318/"
] | I am new to wordpress so i am facing a problem in removing /category/ from wordpress URL
```
http://domain/category/category-name
```
So i would like to know how to remove /category/ from the url. I have tried various solutions like
```
Go to Settings >> Permalinks and select Custom and enter: /%category%/%postna... | There is a plugin for that called WP No Category Base. As the name suggests this plugin will completely remove the mandatory 'Category Base' from your category permalinks ( e.g. myblog.com/category/my-category/ to myblog.com/my-category/ ).
<https://wordpress.org/plugins/wp-no-category-base/> |
151,881 | <p>i need your help :)</p>
<p>I've made this custom Mysql query on WordPress:</p>
<pre><code> $querystr = "
SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE post_id IN(
SELECT DISTINCT wpostmeta.post_id
FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
WHERE wposts.ID = wpostmeta... | [
{
"answer_id": 151894,
"author": "TBI Infotech",
"author_id": 52417,
"author_profile": "https://wordpress.stackexchange.com/users/52417",
"pm_score": -1,
"selected": false,
"text": "<p>To ADD in the query search for \"Category name\" or \"Category ID\" you have to apply inner join with... | 2014/06/26 | [
"https://wordpress.stackexchange.com/questions/151881",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18583/"
] | i need your help :)
I've made this custom Mysql query on WordPress:
```
$querystr = "
SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE post_id IN(
SELECT DISTINCT wpostmeta.post_id
FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
WHERE wposts.ID = wpostmeta.post_id
AND wpostmeta.met... | If I'm not missing something, the below should work for you. It is pretty much straight from the [Codex: WP\_Query - Custom Field Parameters](http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters). Do it like this:
```
$args = array(
'post_type' => 'post',
'meta_query' => array(
'... |
151,885 | <p>I have displayed the post title within the anchor tag after which I've set the permalink. The permalink, however, is not working with the same title that came from the post. It's like getting the previous link that just clicked. It's going to the same address over and over again and not to exact post link.</p>
<pre... | [
{
"answer_id": 151886,
"author": "engelen",
"author_id": 40403,
"author_profile": "https://wordpress.stackexchange.com/users/40403",
"pm_score": 1,
"selected": false,
"text": "<p>First of all, <a href=\"https://wordpress.stackexchange.com/questions/1753/when-should-you-use-wp-query-vs-qu... | 2014/06/26 | [
"https://wordpress.stackexchange.com/questions/151885",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54788/"
] | I have displayed the post title within the anchor tag after which I've set the permalink. The permalink, however, is not working with the same title that came from the post. It's like getting the previous link that just clicked. It's going to the same address over and over again and not to exact post link.
```
<a ... | Firstly, you should never use [`query_posts`](http://codex.wordpress.org/Function_Reference/query_posts) to construct custom queries. This is not just my emphasis, but the codex as well. The one big problem with `query_posts` is, it many circumstances, pagination fails
>
> **Note:** This function isn't meant to be us... |
151,897 | <p>I'm looking for the best way to go about creating, probably, custom post type where you can filter in the categories related to that custom post type in the sidebar. </p>
<p>Here is the website I'm working <a href="http://ustfiof.mmidevsite2.com/health-science/" rel="nofollow">on</a>. Originally the student and don... | [
{
"answer_id": 151886,
"author": "engelen",
"author_id": 40403,
"author_profile": "https://wordpress.stackexchange.com/users/40403",
"pm_score": 1,
"selected": false,
"text": "<p>First of all, <a href=\"https://wordpress.stackexchange.com/questions/1753/when-should-you-use-wp-query-vs-qu... | 2014/06/26 | [
"https://wordpress.stackexchange.com/questions/151897",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27824/"
] | I'm looking for the best way to go about creating, probably, custom post type where you can filter in the categories related to that custom post type in the sidebar.
Here is the website I'm working [on](http://ustfiof.mmidevsite2.com/health-science/). Originally the student and donor profiles should be some type of p... | Firstly, you should never use [`query_posts`](http://codex.wordpress.org/Function_Reference/query_posts) to construct custom queries. This is not just my emphasis, but the codex as well. The one big problem with `query_posts` is, it many circumstances, pagination fails
>
> **Note:** This function isn't meant to be us... |
151,924 | <p>I want to load some specific css to change color of body element of front/home page of WP. Within my themes function file, the following code seems to work, but can someone please tell me if it is "proper"?</p>
<pre><code>//Adding and Encuing styles for Front Page
add_action( 'template_redirect', 'front_page_design... | [
{
"answer_id": 151886,
"author": "engelen",
"author_id": 40403,
"author_profile": "https://wordpress.stackexchange.com/users/40403",
"pm_score": 1,
"selected": false,
"text": "<p>First of all, <a href=\"https://wordpress.stackexchange.com/questions/1753/when-should-you-use-wp-query-vs-qu... | 2014/06/26 | [
"https://wordpress.stackexchange.com/questions/151924",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48604/"
] | I want to load some specific css to change color of body element of front/home page of WP. Within my themes function file, the following code seems to work, but can someone please tell me if it is "proper"?
```
//Adding and Encuing styles for Front Page
add_action( 'template_redirect', 'front_page_design' );
function... | Firstly, you should never use [`query_posts`](http://codex.wordpress.org/Function_Reference/query_posts) to construct custom queries. This is not just my emphasis, but the codex as well. The one big problem with `query_posts` is, it many circumstances, pagination fails
>
> **Note:** This function isn't meant to be us... |
151,932 | <p>** <strong>This question is outdated!</strong> **</p>
<p>I use the bellow function to disable a plugin update. It works, because I use an old version of this plugin and it does not show me that a newer version exists, but, however, I get a warning on line 2: <em>Attempt to modify property of non-object</em>. How to... | [
{
"answer_id": 151940,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": false,
"text": "<p>Some simple php, check if it's set before trying to unset it.</p>\n\n<pre><code>function my_filter_plugin_updates(... | 2014/06/26 | [
"https://wordpress.stackexchange.com/questions/151932",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25187/"
] | \*\* **This question is outdated!** \*\*
I use the bellow function to disable a plugin update. It works, because I use an old version of this plugin and it does not show me that a newer version exists, but, however, I get a warning on line 2: *Attempt to modify property of non-object*. How to fix this?
```
function m... | Some simple php, check if it's set before trying to unset it.
```
function my_filter_plugin_updates( $value ) {
if( isset( $value->response['duplicator/duplicator.php'] ) )
unset( $value->response['duplicator/duplicator.php'] ); //Duplicator
return $value;
}
add_filter( 'site_transient_update_plugins', '... |
151,935 | <p>I created the foreach loop to display post images, but It displays them from last to first, how can I make It to displays from first to last ;) ? </p>
<pre><code> <?php $args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => $... | [
{
"answer_id": 151936,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 0,
"selected": false,
"text": "<p>Re-reverse the array!</p>\n\n<pre><code> if ( $attachments ) {\n\n$attachments = array_reverse( $attachm... | 2014/06/26 | [
"https://wordpress.stackexchange.com/questions/151935",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51068/"
] | I created the foreach loop to display post images, but It displays them from last to first, how can I make It to displays from first to last ;) ?
```
<?php $args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => $post->ID
);
$attac... | Why wouldn't you just pull them in the order you need instead of reversing the array?
```
$args = array(
'post_type' => 'attachment',
'posts_per_page' => -1, // correct key is posts_per_page, not numberposts
'orderby' => 'date'
'order' => 'ASC',
'post_parent' => $post->ID
);
$attachments = get_posts( $args ... |
151,944 | <p>Setting up the WP Customizer options, where it only writes CSS to the head if the value is not the default for that setting. BUT... sometimes the customizer will save the HEX value in all caps and other times it's lowercase. The defaults are all set as capitalized values, and even if it appears they're capitalized v... | [
{
"answer_id": 151936,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 0,
"selected": false,
"text": "<p>Re-reverse the array!</p>\n\n<pre><code> if ( $attachments ) {\n\n$attachments = array_reverse( $attachm... | 2014/06/26 | [
"https://wordpress.stackexchange.com/questions/151944",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54808/"
] | Setting up the WP Customizer options, where it only writes CSS to the head if the value is not the default for that setting. BUT... sometimes the customizer will save the HEX value in all caps and other times it's lowercase. The defaults are all set as capitalized values, and even if it appears they're capitalized valu... | Why wouldn't you just pull them in the order you need instead of reversing the array?
```
$args = array(
'post_type' => 'attachment',
'posts_per_page' => -1, // correct key is posts_per_page, not numberposts
'orderby' => 'date'
'order' => 'ASC',
'post_parent' => $post->ID
);
$attachments = get_posts( $args ... |
151,950 | <p>Whenever I use a JavaScript path to /images/imagename.jpg or within CSS ie. </p>
<p><code>background: url(../images/imagename.jpg)</code></p>
<p>works fine sitewide giving me an expected path to an image that looks like this:</p>
<p><code>http://localhost/projectname/wp-content/themes/bonestheme/library/images/im... | [
{
"answer_id": 151936,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 0,
"selected": false,
"text": "<p>Re-reverse the array!</p>\n\n<pre><code> if ( $attachments ) {\n\n$attachments = array_reverse( $attachm... | 2014/06/27 | [
"https://wordpress.stackexchange.com/questions/151950",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18726/"
] | Whenever I use a JavaScript path to /images/imagename.jpg or within CSS ie.
`background: url(../images/imagename.jpg)`
works fine sitewide giving me an expected path to an image that looks like this:
`http://localhost/projectname/wp-content/themes/bonestheme/library/images/imagename.jpg)`
The problem is that that ... | Why wouldn't you just pull them in the order you need instead of reversing the array?
```
$args = array(
'post_type' => 'attachment',
'posts_per_page' => -1, // correct key is posts_per_page, not numberposts
'orderby' => 'date'
'order' => 'ASC',
'post_parent' => $post->ID
);
$attachments = get_posts( $args ... |
151,955 | <p>I'd like to only show the excerpt for the first post in my main query. I was wondering the best way to approach this.</p>
<p>What I have tried so far is:</p>
<ol>
<li>Making a custom homepage and using two queries, one that returns 1
post with an excerpt and another queries that returns posts without.</li>
<li>Jus... | [
{
"answer_id": 151956,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 1,
"selected": false,
"text": "<p>What about something simple like:</p>\n\n<pre><code>$i = 1;\nif( have_posts() ) {\n while( have_posts() ) {\... | 2014/06/27 | [
"https://wordpress.stackexchange.com/questions/151955",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50522/"
] | I'd like to only show the excerpt for the first post in my main query. I was wondering the best way to approach this.
What I have tried so far is:
1. Making a custom homepage and using two queries, one that returns 1
post with an excerpt and another queries that returns posts without.
2. Just using the default querie... | You can use `$wp_query->current_post` in your loop to check the current post. You don't need two loops, one will do the trick If you need excerpt for first post only, you can do something like this. Just remember, the first post in the loop is `0`, and not `1`
```
if ( !$wp_query->current_post > 0 ) :
the_excerpt()... |
151,964 | <p>The code (below) works fine on all pages <strong>but front-page.php</strong> in WordPress.</p>
<p>Specifically, it adds an extra pipe symbol to the beginning of the title tag.</p>
<p>For example, if the following is the homepage of the site, the title looks like this:</p>
<p><code><title>| Acme Widgets | Cu... | [
{
"answer_id": 151974,
"author": "Phil Lewis",
"author_id": 26082,
"author_profile": "https://wordpress.stackexchange.com/users/26082",
"pm_score": -1,
"selected": false,
"text": "<pre><code>elseif (!(is_404()) && (is_single()) || (is_page()) ) {\n</code></pre>\n\n<p>In your conf... | 2014/06/27 | [
"https://wordpress.stackexchange.com/questions/151964",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12116/"
] | The code (below) works fine on all pages **but front-page.php** in WordPress.
Specifically, it adds an extra pipe symbol to the beginning of the title tag.
For example, if the following is the homepage of the site, the title looks like this:
`<title>| Acme Widgets | Custom Widgets for all occasions</title>`
Note th... | I wound up fixing it like this. All pages now work. But it looks ...well ...ugly.
```
<?php if (function_exists('is_tag') && is_tag()) {
single_tag_title('Tag Archive for "'); echo '" | ';
} elseif (is_archive()) {
wp_title(''); echo ' Archive | ';
} elseif (is_search()) {
echo 'Search for "... |
151,966 | <p>I use categories to order my posts into timelines. So for example, <a href="http://newslines.org/jennifer-lopez/" rel="nofollow">Jennifer Lopez</a></p>
<p>There are no subcategories. All categories are on one level.</p>
<p>The top post, "Wants Gomez" actually has two categories: Jennifer Lopez and Selina Gomez. I'... | [
{
"answer_id": 151974,
"author": "Phil Lewis",
"author_id": 26082,
"author_profile": "https://wordpress.stackexchange.com/users/26082",
"pm_score": -1,
"selected": false,
"text": "<pre><code>elseif (!(is_404()) && (is_single()) || (is_page()) ) {\n</code></pre>\n\n<p>In your conf... | 2014/06/27 | [
"https://wordpress.stackexchange.com/questions/151966",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45635/"
] | I use categories to order my posts into timelines. So for example, [Jennifer Lopez](http://newslines.org/jennifer-lopez/)
There are no subcategories. All categories are on one level.
The top post, "Wants Gomez" actually has two categories: Jennifer Lopez and Selina Gomez. I'd like to display only the categories that ... | I wound up fixing it like this. All pages now work. But it looks ...well ...ugly.
```
<?php if (function_exists('is_tag') && is_tag()) {
single_tag_title('Tag Archive for "'); echo '" | ';
} elseif (is_archive()) {
wp_title(''); echo ' Archive | ';
} elseif (is_search()) {
echo 'Search for "... |
151,967 | <p>my custom archives page is :</p>
<pre><code><?php get_header();
print ('<div class="row">');
$archi = wp_get_archives('echo=0');
$archi = explode( '</li>' , $archi );
$archi_count = count($archi);
$count = 1;
$itemCount = 0;
foreach( $archi as $link ) {
$link = str_r... | [
{
"answer_id": 151974,
"author": "Phil Lewis",
"author_id": 26082,
"author_profile": "https://wordpress.stackexchange.com/users/26082",
"pm_score": -1,
"selected": false,
"text": "<pre><code>elseif (!(is_404()) && (is_single()) || (is_page()) ) {\n</code></pre>\n\n<p>In your conf... | 2014/06/27 | [
"https://wordpress.stackexchange.com/questions/151967",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43764/"
] | my custom archives page is :
```
<?php get_header();
print ('<div class="row">');
$archi = wp_get_archives('echo=0');
$archi = explode( '</li>' , $archi );
$archi_count = count($archi);
$count = 1;
$itemCount = 0;
foreach( $archi as $link ) {
$link = str_replace( array( '<li>' , "\n" ... | I wound up fixing it like this. All pages now work. But it looks ...well ...ugly.
```
<?php if (function_exists('is_tag') && is_tag()) {
single_tag_title('Tag Archive for "'); echo '" | ';
} elseif (is_archive()) {
wp_title(''); echo ' Archive | ';
} elseif (is_search()) {
echo 'Search for "... |
151,971 | <p>Why is <code>while()</code> used instead of say <code>if()</code> here:</p>
<pre><code> <?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'single' ); ?>
<?php _s_post_nav(); ?>
<?php
// If comments are open or we have... | [
{
"answer_id": 151973,
"author": "test",
"author_id": 54821,
"author_profile": "https://wordpress.stackexchange.com/users/54821",
"pm_score": 0,
"selected": false,
"text": "<p>You must be use in single post or detail post because you does not get post meta field.\nFor example you have on... | 2014/06/27 | [
"https://wordpress.stackexchange.com/questions/151971",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17185/"
] | Why is `while()` used instead of say `if()` here:
```
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'single' ); ?>
<?php _s_post_nav(); ?>
<?php
// If comments are open or we have at least one comment, load up the comment template
... | As [the WordPress Codex for `have_posts`](http://codex.wordpress.org/Function_Reference/have_posts) points out:
>
> As a side effect, have\_posts starts, steps through, or resets The Loop. At the end of the loop, have\_posts returns 0 after calling rewind\_posts.
>
>
>
Looking at the source as it stands today: a... |
151,978 | <p>I have three dropdown filters on the front site to select country, territory and region and need to redirect the user to the country/territory/region page depending upon the filter values on click of Submit button.</p>
<p>FYI, I have pages with the same slug.eg- example.com/country-name/territory-name/region-name</... | [
{
"answer_id": 151985,
"author": "TBI Infotech",
"author_id": 52417,
"author_profile": "https://wordpress.stackexchange.com/users/52417",
"pm_score": 1,
"selected": false,
"text": "<p>Please make sure these is no data output or blank spaces above <code>wp_redirect( $final_url ); exit;</c... | 2014/06/27 | [
"https://wordpress.stackexchange.com/questions/151978",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34169/"
] | I have three dropdown filters on the front site to select country, territory and region and need to redirect the user to the country/territory/region page depending upon the filter values on click of Submit button.
FYI, I have pages with the same slug.eg- example.com/country-name/territory-name/region-name
I am tryin... | Please make sure these is no data output or blank spaces above `wp_redirect( $final_url ); exit;` otherwise this warning will always appear.
Also optionally you can use
```
<?php
//Php code
?>
<script type="text/javascript">
document.location.href="http://example.com";
</script>
<?php
//php code
?>
``` |
151,991 | <p>one of my site's wp-admin is not accesible but the site front part is loading. This happens after i accessed the site from my new server second time. at first nothing happens and i can logg into dashboard. then after i logged out and second time try to login this error happens. when accessing the mysite.com/wp-admin... | [
{
"answer_id": 151994,
"author": "Varun Sridharan",
"author_id": 18746,
"author_profile": "https://wordpress.stackexchange.com/users/18746",
"pm_score": 0,
"selected": false,
"text": "<p>there is a missing.. a file which is required wordpress is missing so admin is not working properly t... | 2014/06/27 | [
"https://wordpress.stackexchange.com/questions/151991",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40999/"
] | one of my site's wp-admin is not accesible but the site front part is loading. This happens after i accessed the site from my new server second time. at first nothing happens and i can logg into dashboard. then after i logged out and second time try to login this error happens. when accessing the mysite.com/wp-admin th... | There are following possibilities when you cann't open wp-admin
1.There should be some file missing
2.Some function deny to login in themes files
3.Some plugin may also create issue
Solution:-
1.Replace all files from new WordPress except wp-content and wp-config file
1. Rename your theme folder in wp-content
2. ... |
152,002 | <p>I've been digging for documentation on how to change HTML output for the "Custom menu" which you place in optional widget. So its clear what I meen I have attached an image of the widget block here: </p>
<p><img src="https://i.stack.imgur.com/jjMVE.png" alt="Custom menu"> </p>
<p>The output from this element is lo... | [
{
"answer_id": 152003,
"author": "Christoph Daum",
"author_id": 54549,
"author_profile": "https://wordpress.stackexchange.com/users/54549",
"pm_score": -1,
"selected": false,
"text": "<p>To modify the menu, you mainly will use the menu walker class. See here <a href=\"http://codex.wordpr... | 2014/06/27 | [
"https://wordpress.stackexchange.com/questions/152002",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54836/"
] | I've been digging for documentation on how to change HTML output for the "Custom menu" which you place in optional widget. So its clear what I meen I have attached an image of the widget block here:

The output from this element is looking like this:
```
<div clas... | Working with raw data is always a bit dirty. The clean approach to do that would probably be to implement an own widget, that does exactly what you want it to do.
You can learn more about using the Widget API here: <http://codex.wordpress.org/Widgets_API>
There are also some great examples there. Not that hard to und... |
152,004 | <p>In WordPress I am using both <code>the_permalink()</code> and <code>get_permalink()</code> functions, but I cannot get any difference in the output of both functions. What is the difference between both functions?</p>
| [
{
"answer_id": 152006,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 5,
"selected": true,
"text": "<p><code>the_permalink</code> echos out the permalink of the current post to the frontend.</p>\n\n<p><code>get_p... | 2014/06/27 | [
"https://wordpress.stackexchange.com/questions/152004",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54837/"
] | In WordPress I am using both `the_permalink()` and `get_permalink()` functions, but I cannot get any difference in the output of both functions. What is the difference between both functions? | `the_permalink` echos out the permalink of the current post to the frontend.
`get_permalink` however returns it as a variable, but does not echo it out. You can also pass a post ID to it if you want the permalink of another post.
`the_permalink` is equivalent to:
```
echo get_permalink();
```
Which is very close t... |
152,018 | <p>Registered a custom post type (<code>xyz</code>) and after that added a meta box using <a href="http://code.tutsplus.com/tutorials/reusable-custom-meta-boxes-part-1-intro-and-basic-fields--wp-23259" rel="nofollow noreferrer">this excellent Tuts+ tutorial</a>, so then I can reduce the usage of 'Advanced Custom Fields... | [
{
"answer_id": 152024,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 0,
"selected": false,
"text": "<p>The codex of WordPress is not perfectly, but often you find a documentation to the functions.\nsee <a href=\"http... | 2014/06/27 | [
"https://wordpress.stackexchange.com/questions/152018",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22728/"
] | Registered a custom post type (`xyz`) and after that added a meta box using [this excellent Tuts+ tutorial](http://code.tutsplus.com/tutorials/reusable-custom-meta-boxes-part-1-intro-and-basic-fields--wp-23259), so then I can reduce the usage of 'Advanced Custom Fields' where I can (but I love ACF most). But doing so, ... | To answer #3, just search ACF's `input.css` file for the class `no-box` and you'll see how it works. If you view the meta box in the context of the edit screen, and delete the `no-box` class using your browser's web inspector, you'll see that it will appear as and can be sorted like a normal meta box, so it is entirely... |
152,022 | <p>The past couple of hours I am trying to find out what is the problem with this...</p>
<pre><code><?php $related_posts = get_field('related_posts'); ?>
<?php if ($related_posts) : ?>
<div class="related-projects_items-list-container">
<div class="comments-area-title">
... | [
{
"answer_id": 152023,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 0,
"selected": false,
"text": "<p>Add a if statement, that you have a thumbnail, before you get the thumbnail.</p>\n\n<pre><code>if ( has_post_thum... | 2014/06/27 | [
"https://wordpress.stackexchange.com/questions/152022",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45047/"
] | The past couple of hours I am trying to find out what is the problem with this...
```
<?php $related_posts = get_field('related_posts'); ?>
<?php if ($related_posts) : ?>
<div class="related-projects_items-list-container">
<div class="comments-area-title">
<h4 class="hN"><?php _e('<em>Related</... | This Trac ticket here describes your problem and the cause:
<https://core.trac.wordpress.org/ticket/26321>
>
> I got a warning/error related to `update_post_thumbnail_cache()`
> function:
>
>
>
> >
> > Warning: Invalid argument supplied for foreach() in ./wp-includes/post-thumbnail-template.php on line 64
> > ... |
152,033 | <p>I have a post type the uses post_save to take the address from the post-meta and retrieve the lat/lng coordinates from the Google API. I need a way of notifying the user if there was an issue with retrieving the coordintes. I tried using admin_notices, but nothing displayed:</p>
<pre><code>public static function up... | [
{
"answer_id": 152059,
"author": "jonathanbardo",
"author_id": 47837,
"author_profile": "https://wordpress.stackexchange.com/users/47837",
"pm_score": 6,
"selected": true,
"text": "<p>The reason this doesn't work is because there is a redirection happening after the save_post action. One... | 2014/06/27 | [
"https://wordpress.stackexchange.com/questions/152033",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47750/"
] | I have a post type the uses post\_save to take the address from the post-meta and retrieve the lat/lng coordinates from the Google API. I need a way of notifying the user if there was an issue with retrieving the coordintes. I tried using admin\_notices, but nothing displayed:
```
public static function update_notice(... | The reason this doesn't work is because there is a redirection happening after the save\_post action. One way you can achieve what you want is by implementing a quick work around using query vars.
Here is a sample class to demonstrate:
```
class My_Awesome_Plugin {
public function __construct(){
add_action( 'sav... |
152,041 | <p>I was asked by a customer about the possibility to put a menu from a WP installation into another WP, whereas are independent installations, each one for its domain. The point is: I developed a website in WP (using Woocommerce) and months after we developed a blog, with another layout structure but keeping the visua... | [
{
"answer_id": 152059,
"author": "jonathanbardo",
"author_id": 47837,
"author_profile": "https://wordpress.stackexchange.com/users/47837",
"pm_score": 6,
"selected": true,
"text": "<p>The reason this doesn't work is because there is a redirection happening after the save_post action. One... | 2014/06/27 | [
"https://wordpress.stackexchange.com/questions/152041",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/46098/"
] | I was asked by a customer about the possibility to put a menu from a WP installation into another WP, whereas are independent installations, each one for its domain. The point is: I developed a website in WP (using Woocommerce) and months after we developed a blog, with another layout structure but keeping the visual I... | The reason this doesn't work is because there is a redirection happening after the save\_post action. One way you can achieve what you want is by implementing a quick work around using query vars.
Here is a sample class to demonstrate:
```
class My_Awesome_Plugin {
public function __construct(){
add_action( 'sav... |
152,057 | <p>I need your help. I am trying to mass delete attachments from a custom post type ('book') using a sql query. I found this snippet on the wordpress form: <a href="http://wordpress.org/support/topic/delete-100000-images-from-media-library?replies=8#post-3270530" rel="nofollow">Wordpress.org</a></p>
<p>I tested it on ... | [
{
"answer_id": 152061,
"author": "eyoung100",
"author_id": 51113,
"author_profile": "https://wordpress.stackexchange.com/users/51113",
"pm_score": 0,
"selected": false,
"text": "<p>Combining two methods here:</p>\n\n<pre><code>$args = array(\n'post_type' => 'attachment',\n'numberposts... | 2014/06/27 | [
"https://wordpress.stackexchange.com/questions/152057",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51781/"
] | I need your help. I am trying to mass delete attachments from a custom post type ('book') using a sql query. I found this snippet on the wordpress form: [Wordpress.org](http://wordpress.org/support/topic/delete-100000-images-from-media-library?replies=8#post-3270530)
I tested it on my local computer, and it removes al... | You can do it with native WordPress codex calls like this
( source <http://badlywired.com/technical-stuff/2014/11/10/code-to-delete-all-images-from-wordpress-or-nearly-all/> )
```
<?php
/* create this code in a file in the main wordpress directory e.g. delmedia.php
and access it via mydomain.com/delmedia.php
*/
// In... |
152,066 | <p>My WordPress install (with the following plugins) randomly creates Draft posts whenever I load the posts page. Is there a way to find out which plugin is doing this (aside from deactivating)? Has anyone had this problem?</p>
<p><code>
Admin Tree View
Advanced Custom Fields
ACF: Flexible Content Field
ACF: Repeater ... | [
{
"answer_id": 152061,
"author": "eyoung100",
"author_id": 51113,
"author_profile": "https://wordpress.stackexchange.com/users/51113",
"pm_score": 0,
"selected": false,
"text": "<p>Combining two methods here:</p>\n\n<pre><code>$args = array(\n'post_type' => 'attachment',\n'numberposts... | 2014/06/27 | [
"https://wordpress.stackexchange.com/questions/152066",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36303/"
] | My WordPress install (with the following plugins) randomly creates Draft posts whenever I load the posts page. Is there a way to find out which plugin is doing this (aside from deactivating)? Has anyone had this problem?
`Admin Tree View
Advanced Custom Fields
ACF: Flexible Content Field
ACF: Repeater Field
Breadcrumb... | You can do it with native WordPress codex calls like this
( source <http://badlywired.com/technical-stuff/2014/11/10/code-to-delete-all-images-from-wordpress-or-nearly-all/> )
```
<?php
/* create this code in a file in the main wordpress directory e.g. delmedia.php
and access it via mydomain.com/delmedia.php
*/
// In... |
152,087 | <p>I have 40+ posts on my blog. Only one of them is going to a 404 page when I click the title (visit the permalink).</p>
<p>To see it in action: <a href="http://thegrovestead.com/tag/strawberries/" rel="nofollow">http://thegrovestead.com/tag/strawberries/</a></p>
<p>Look for the post "Cure for the common slug" and c... | [
{
"answer_id": 152098,
"author": "Matt Royal",
"author_id": 51860,
"author_profile": "https://wordpress.stackexchange.com/users/51860",
"pm_score": 1,
"selected": false,
"text": "<p>It is not listed in the Codex but perhaps the word 'slug' in the pages URL is a reserved word? Just a wild... | 2014/06/28 | [
"https://wordpress.stackexchange.com/questions/152087",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54860/"
] | I have 40+ posts on my blog. Only one of them is going to a 404 page when I click the title (visit the permalink).
To see it in action: <http://thegrovestead.com/tag/strawberries/>
Look for the post "Cure for the common slug" and click the title (permalink: <http://thegrovestead.com/cure-for-the-common-slug/>)
You w... | It is not listed in the Codex but perhaps the word 'slug' in the pages URL is a reserved word? Just a wild guess and could be completely wrong. I thought it may be worth mentioning however as others may encounter a similar problem and might be the result of using reserved words.
If you reference the link to the WordPr... |
152,088 | <p>I'm new here, and to coding! I've been working hard (so, so hard...so hard) to create my website and with occasional help I've created a look and feel I like using some custom get_post_meta fields for my banner and background under header.php. </p>
<pre><code><div id="page" class="hfeed site">
<?php do_act... | [
{
"answer_id": 152098,
"author": "Matt Royal",
"author_id": 51860,
"author_profile": "https://wordpress.stackexchange.com/users/51860",
"pm_score": 1,
"selected": false,
"text": "<p>It is not listed in the Codex but perhaps the word 'slug' in the pages URL is a reserved word? Just a wild... | 2014/06/28 | [
"https://wordpress.stackexchange.com/questions/152088",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54857/"
] | I'm new here, and to coding! I've been working hard (so, so hard...so hard) to create my website and with occasional help I've created a look and feel I like using some custom get\_post\_meta fields for my banner and background under header.php.
```
<div id="page" class="hfeed site">
<?php do_action( 'before' ); ?>
<... | It is not listed in the Codex but perhaps the word 'slug' in the pages URL is a reserved word? Just a wild guess and could be completely wrong. I thought it may be worth mentioning however as others may encounter a similar problem and might be the result of using reserved words.
If you reference the link to the WordPr... |
152,091 | <p>I've set medium sized images to a custom size which should allow for both of the images to align horizontally within the post. (The full post width is 880px, medium images are set to 413px.)</p>
<p>My challenge is that the images are not evenly aligned - the image on the right is always a little lower UNLESS there ... | [
{
"answer_id": 152095,
"author": "René Skou",
"author_id": 50677,
"author_profile": "https://wordpress.stackexchange.com/users/50677",
"pm_score": 0,
"selected": false,
"text": "<p>Remove your line break tag between your images.</p>\n\n<p>Example:</p>\n\n<pre><code><img src=\"\" alt=\... | 2014/06/28 | [
"https://wordpress.stackexchange.com/questions/152091",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14606/"
] | I've set medium sized images to a custom size which should allow for both of the images to align horizontally within the post. (The full post width is 880px, medium images are set to 413px.)
My challenge is that the images are not evenly aligned - the image on the right is always a little lower UNLESS there is another... | If this is how it looks:
```
<img class="alignleft size-medium wp-image-8530" alt="..." src="#" width="413" height="275" />
<img class="alignleft size-medium wp-image-8529" alt="..." src="#" width="413" height="275" />
```
Then you have to put them together like this:
```
<img class="alignleft size-medium wp-image-... |
152,097 | <p>I am trying to add <code>facebook share</code> functionality to my <code>wordpress</code> posts. in my <code>wp loop</code> i have a share button</p>
<pre><code><a class="action_button" href="javascript:void(0)" id="share_button" target="_blank"> share this</a>
</code></pre>
<p>i am not getting <code>... | [
{
"answer_id": 152105,
"author": "astrovish",
"author_id": 54862,
"author_profile": "https://wordpress.stackexchange.com/users/54862",
"pm_score": -1,
"selected": false,
"text": "<p>Try removing <strong>single quotes</strong> from your code like this:</p>\n\n<pre><code>name: ' <?php ... | 2014/06/28 | [
"https://wordpress.stackexchange.com/questions/152097",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52105/"
] | I am trying to add `facebook share` functionality to my `wordpress` posts. in my `wp loop` i have a share button
```
<a class="action_button" href="javascript:void(0)" id="share_button" target="_blank"> share this</a>
```
i am not getting `post title ,post thumpnail` etc. what is wrong with my code.
and before sta... | The Javascript is outside the loop, so php can never access `get_the_title()`, `get_permalink()` and `get_the_post_thumbnail()` from there.
What I'd do is include those somewhere in the loop, for instance:
```
<div class="entry-content">
<h2 class="post-title"><?php the_title(); ?></h2>
<a class="share-button... |
152,117 | <p>How to display some information of featured image in post.</p>
<p>I need to display:</p>
<p><strong>1.</strong></p>
<p>a. <strong>Image file size (in kb or MB)</strong></p>
<p>b. <strong>Image type (.jpg,.gif...)</strong>, </p>
<p>c. <strong>Bare image name, with and/or without image extension (some-image-file-... | [
{
"answer_id": 152120,
"author": "Pat Gilmour",
"author_id": 48679,
"author_profile": "https://wordpress.stackexchange.com/users/48679",
"pm_score": 3,
"selected": true,
"text": "<p>Question 1: use <a href=\"http://codex.wordpress.org/Function_Reference/wp_get_attachment_metadata\" rel=\... | 2014/06/28 | [
"https://wordpress.stackexchange.com/questions/152117",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25053/"
] | How to display some information of featured image in post.
I need to display:
**1.**
a. **Image file size (in kb or MB)**
b. **Image type (.jpg,.gif...)**,
c. **Bare image name, with and/or without image extension (some-image-file-name.jpg)**.
Also, if it possible it would be nice to show this too:
d. orientati... | Question 1: use [`wp_get_attachment_metadata` in the Codex](http://codex.wordpress.org/Function_Reference/wp_get_attachment_metadata)
or the search function on this forum!
Question 2: Put this in one of your functions. It will echo the Alt text for the image.
```
$img_id = get_post_thumbnail_id( get_the_ID() ); //Not... |
152,137 | <p>I made a custom theme and wonder how could I extract all translatable strings to a .po file so I can translate it. Do I need WPML plugin?</p>
<p>Ex: I have a string "soccer" which is written as <code>_e('soccer','mytheme');</code> and I want to translate it to "futebol" but how can I transport it to a .po file?</p>... | [
{
"answer_id": 152142,
"author": "Will",
"author_id": 17940,
"author_profile": "https://wordpress.stackexchange.com/users/17940",
"pm_score": 3,
"selected": true,
"text": "<p>One way is to use the WordPress i18n tools. I had to checkout WordPress trunk to make it work. On the command lin... | 2014/06/28 | [
"https://wordpress.stackexchange.com/questions/152137",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43151/"
] | I made a custom theme and wonder how could I extract all translatable strings to a .po file so I can translate it. Do I need WPML plugin?
Ex: I have a string "soccer" which is written as `_e('soccer','mytheme');` and I want to translate it to "futebol" but how can I transport it to a .po file? | One way is to use the WordPress i18n tools. I had to checkout WordPress trunk to make it work. On the command line:
```
svn co http://develop.svn.wordpress.org/trunk
```
once you have trunk somewhere, you'll then want to call the `makepot` script. Again, on the command line:
```
php /path/to/wordpress/trunk/tools/i... |
152,206 | <p>I put my site in maintenance mode using this hook in <code>functions.php</code>,</p>
<pre><code>function activate_maintenance_mode() {
//If the current user is NOT an 'Administrator' or NOT 'Super Admin' then display Maintenance Page.
if ( !(current_user_can( 'administrator' ) || current_user_can( 'super a... | [
{
"answer_id": 152207,
"author": "Praveen",
"author_id": 26393,
"author_profile": "https://wordpress.stackexchange.com/users/26393",
"pm_score": 0,
"selected": false,
"text": "<p>I think the code is wrong, you are basically using WP_die for super admins when you say :</p>\n\n<pre><code>i... | 2014/06/30 | [
"https://wordpress.stackexchange.com/questions/152206",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51091/"
] | I put my site in maintenance mode using this hook in `functions.php`,
```
function activate_maintenance_mode() {
//If the current user is NOT an 'Administrator' or NOT 'Super Admin' then display Maintenance Page.
if ( !(current_user_can( 'administrator' ) || current_user_can( 'super admin' ))) {
//Kil... | Since you are using the W3 total cache plugin, So The HTML code will be cached in the wp-content/cache folder. So Delete Cache folder from wp-content directory.
Now remove the function activate\_maintenance\_mode() and check the site now...
If the problem exists , Delete the W3 total Cache Constant from wp-config.php... |
152,222 | <p>I am trying to remove the shortcode from a specific post type, in this case link. I used this code on my functions.php but it removes the shortcode from the_content for every post type. </p>
<pre><code><?php
function remove_shortcodes( $content )
{
return strip_shortcodes( $content );
}
add_filter( 'the_cont... | [
{
"answer_id": 152224,
"author": "Horttcore",
"author_id": 1379,
"author_profile": "https://wordpress.stackexchange.com/users/1379",
"pm_score": 1,
"selected": false,
"text": "<p>This will remove shortcodes for the link post type. Maybe you wanna combine it with <a href=\"http://codex.wo... | 2014/06/30 | [
"https://wordpress.stackexchange.com/questions/152222",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20460/"
] | I am trying to remove the shortcode from a specific post type, in this case link. I used this code on my functions.php but it removes the shortcode from the\_content for every post type.
```
<?php
function remove_shortcodes( $content )
{
return strip_shortcodes( $content );
}
add_filter( 'the_content', 'remove_sh... | You would need to use [WordPress Conditional Tags](http://codex.wordpress.org/Conditional_Tags#A_Post_Type) to query if this page is the custom post type you are wanting to target and then if it is remove shortcode.
Untested but you can try this:
```
function remove_shortcodes( $content ) {
if ( get_post... |
152,231 | <p>Is it possible to have a different back-end colour scheme selected for the different sites of a multisite?</p>
<p>i.e. "Sunrise" for Site A and "Midnight" for Site B</p>
<p>If it's not possible for the user to setup could it be enforced through a plugin or the theme?</p>
| [
{
"answer_id": 152255,
"author": "elvismdev",
"author_id": 44982,
"author_profile": "https://wordpress.stackexchange.com/users/44982",
"pm_score": 3,
"selected": true,
"text": "<p>Add to your functions.php file the following code, this will hook into your admin header section and will pl... | 2014/06/30 | [
"https://wordpress.stackexchange.com/questions/152231",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48424/"
] | Is it possible to have a different back-end colour scheme selected for the different sites of a multisite?
i.e. "Sunrise" for Site A and "Midnight" for Site B
If it's not possible for the user to setup could it be enforced through a plugin or the theme? | Add to your functions.php file the following code, this will hook into your admin header section and will place the style you chose accordingly to the matching site.
```
add_action('admin_enqueue_scripts', 'my_admin_background');
function my_admin_background() {
wp_enqueue_style(
'custom-style',
get_templat... |
152,233 | <p>This is the url: <a href="http://www.step-immobilien.com/en/projects/house-1-worthersee/" rel="nofollow">HOUSE 1</a></p>
<p>I have custom post type "Properties".For each new property, I can select "Property Type", "Property Status", "Property Location" taxomony. This page is using its own template, so I was wonderi... | [
{
"answer_id": 152242,
"author": "Bysander",
"author_id": 47618,
"author_profile": "https://wordpress.stackexchange.com/users/47618",
"pm_score": 2,
"selected": true,
"text": "<p>If you are already on the page of the house (in the loop of the post) you want then something like this shoul... | 2014/06/30 | [
"https://wordpress.stackexchange.com/questions/152233",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19499/"
] | This is the url: [HOUSE 1](http://www.step-immobilien.com/en/projects/house-1-worthersee/)
I have custom post type "Properties".For each new property, I can select "Property Type", "Property Status", "Property Location" taxomony. This page is using its own template, so I was wondering - can I modify the query for that... | If you are already on the page of the house (in the loop of the post) you want then something like this should work. I imagine the values are saved as post meta???
If so I had to do something similar and managed to achieve it like this although I'm sure someone out there may have a better way round.
```
$ThisPostID =... |
152,234 | <p>is it possible to add a dynamic class to a div using a filter in the functions.php? I know it's possible for the body-tag - also for a custom defined div with an id?</p>
<pre><code>if ( !is_search() ) {
$customclass = 'myclass';
}
</code></pre>
| [
{
"answer_id": 152243,
"author": "Matt Royal",
"author_id": 51860,
"author_profile": "https://wordpress.stackexchange.com/users/51860",
"pm_score": 1,
"selected": false,
"text": "<p>You could try using one of the following methods, I don't think there is a specific way to do this other t... | 2014/06/30 | [
"https://wordpress.stackexchange.com/questions/152234",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54942/"
] | is it possible to add a dynamic class to a div using a filter in the functions.php? I know it's possible for the body-tag - also for a custom defined div with an id?
```
if ( !is_search() ) {
$customclass = 'myclass';
}
``` | You could try using one of the following methods, I don't think there is a specific way to do this other than these two options below.
**Option 1**
In your template file, add the `post_class();` to your div like this:
```
<div id="your-div" <?php post_class(); ?> >
```
Then you can use `post_class` filter in your ... |
152,249 | <p>I'm trying to create a plugin that will delete pictures and additional info from database on deleting custom post (sp_venue) via admin panel (wp-admin/edit-tags.php)</p>
<p>In the plugin I'm using this to catch the event:</p>
<pre><code>add_action( 'delete_post', 'kg_delete_post' );
function kg_delete_post($postI... | [
{
"answer_id": 152277,
"author": "Adam",
"author_id": 54761,
"author_profile": "https://wordpress.stackexchange.com/users/54761",
"pm_score": 0,
"selected": false,
"text": "<p>I would take a look at <a href=\"http://codex.wordpress.org/Plugin_API/Action_Reference/delete_post\" rel=\"nofo... | 2014/06/30 | [
"https://wordpress.stackexchange.com/questions/152249",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54951/"
] | I'm trying to create a plugin that will delete pictures and additional info from database on deleting custom post (sp\_venue) via admin panel (wp-admin/edit-tags.php)
In the plugin I'm using this to catch the event:
```
add_action( 'delete_post', 'kg_delete_post' );
function kg_delete_post($postId) {
$post = ge... | Solved, by adding my own js in admin panel to customize the click on delete button. |
152,251 | <p>I am working with a Wordpress site and have created a custom page in <code>/home/planmyme/public_html/php/</code> with the name <code>response.php</code>. On this page I am getting a value to insert in the <code>wp_postmeta</code> table (value examples: transaction ID, purchase ID, order ID, or item name), but I am ... | [
{
"answer_id": 152297,
"author": "s1lv3r",
"author_id": 27536,
"author_profile": "https://wordpress.stackexchange.com/users/27536",
"pm_score": 1,
"selected": false,
"text": "<p>The error message basically says that <code>$wpdb</code> is not an object so you can't call any methods on it.... | 2014/06/30 | [
"https://wordpress.stackexchange.com/questions/152251",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39122/"
] | I am working with a Wordpress site and have created a custom page in `/home/planmyme/public_html/php/` with the name `response.php`. On this page I am getting a value to insert in the `wp_postmeta` table (value examples: transaction ID, purchase ID, order ID, or item name), but I am not able to insert it.
I am using t... | The error message basically says that `$wpdb` is not an object so you can't call any methods on it. As we can't see where `$wpdb` is defined in the source you posted it's hard to tell any further details.
Are you even including wordpress in your external file? You need to require `wp-load.php` to use the wordpress fun... |
152,254 | <p>I use this code to display featured image title, caption (excerpt), description (content):</p>
<p><code>echo get_post(get_post_thumbnail_id())->post_title;
echo get_post(get_post_thumbnail_id())->post_excerpt;
echo get_post(get_post_thumbnail_id())->post_content;</code></p>
<p>But, how to check if there i... | [
{
"answer_id": 152256,
"author": "gdaniel",
"author_id": 30984,
"author_profile": "https://wordpress.stackexchange.com/users/30984",
"pm_score": 0,
"selected": false,
"text": "<p>Use <strong>if</strong> statements.</p>\n\n<pre><code>if($caption = get_post(get_post_thumbnail_id())->pos... | 2014/06/30 | [
"https://wordpress.stackexchange.com/questions/152254",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25053/"
] | I use this code to display featured image title, caption (excerpt), description (content):
`echo get_post(get_post_thumbnail_id())->post_title;
echo get_post(get_post_thumbnail_id())->post_excerpt;
echo get_post(get_post_thumbnail_id())->post_content;`
But, how to check if there is any of those fields first?
For exa... | It's more a programming question, but try this:
```
$post = get_post( get_post_thumbnail_id() );
if ( !isset( $post->post_title ) ) {
echo 'Sorry no title';
} else {
echo $post->post_title;
}
``` |
152,267 | <p>I am migrating a (non-English-language) blog using the <a href="http://theme.wordpress.com/themes/koi/" rel="nofollow">Koi</a> theme on WordPress.com to a self-hosted environment, but see that certain strings are no longer being translated. For example, if my wp-config.php file contains <code>define ('WPLANG', 'de_... | [
{
"answer_id": 152256,
"author": "gdaniel",
"author_id": 30984,
"author_profile": "https://wordpress.stackexchange.com/users/30984",
"pm_score": 0,
"selected": false,
"text": "<p>Use <strong>if</strong> statements.</p>\n\n<pre><code>if($caption = get_post(get_post_thumbnail_id())->pos... | 2014/06/30 | [
"https://wordpress.stackexchange.com/questions/152267",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54948/"
] | I am migrating a (non-English-language) blog using the [Koi](http://theme.wordpress.com/themes/koi/) theme on WordPress.com to a self-hosted environment, but see that certain strings are no longer being translated. For example, if my wp-config.php file contains `define ('WPLANG', 'de_DE')`, then \_most of the theme is ... | It's more a programming question, but try this:
```
$post = get_post( get_post_thumbnail_id() );
if ( !isset( $post->post_title ) ) {
echo 'Sorry no title';
} else {
echo $post->post_title;
}
``` |
152,282 | <p>More of a conceptual question here, than a strict code question:</p>
<p>Working on a site for a musician who wants to list concerts, both upcoming and past. These are custom post types that use a custom field for the date of the show (formatted as yyyymmdd). For queries and sorting, the date of the show is the crit... | [
{
"answer_id": 152256,
"author": "gdaniel",
"author_id": 30984,
"author_profile": "https://wordpress.stackexchange.com/users/30984",
"pm_score": 0,
"selected": false,
"text": "<p>Use <strong>if</strong> statements.</p>\n\n<pre><code>if($caption = get_post(get_post_thumbnail_id())->pos... | 2014/06/30 | [
"https://wordpress.stackexchange.com/questions/152282",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54908/"
] | More of a conceptual question here, than a strict code question:
Working on a site for a musician who wants to list concerts, both upcoming and past. These are custom post types that use a custom field for the date of the show (formatted as yyyymmdd). For queries and sorting, the date of the show is the critical bit o... | It's more a programming question, but try this:
```
$post = get_post( get_post_thumbnail_id() );
if ( !isset( $post->post_title ) ) {
echo 'Sorry no title';
} else {
echo $post->post_title;
}
``` |
152,298 | <p>I'm converting an HTML template into a wordpress theme and I'm having some trouble displaying the post tags within the functions.php file. What I would like to do is add the following code into the functions file with the HTML code. I have been trying for a few days now and I have already been to the codex but nothi... | [
{
"answer_id": 152302,
"author": "s1lv3r",
"author_id": 27536,
"author_profile": "https://wordpress.stackexchange.com/users/27536",
"pm_score": 2,
"selected": false,
"text": "<p>I think you are searching for the <a href=\"http://codex.wordpress.org/Function_Reference/get_tags\" rel=\"nof... | 2014/06/30 | [
"https://wordpress.stackexchange.com/questions/152298",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38050/"
] | I'm converting an HTML template into a wordpress theme and I'm having some trouble displaying the post tags within the functions.php file. What I would like to do is add the following code into the functions file with the HTML code. I have been trying for a few days now and I have already been to the codex but nothing ... | I think you are searching for the [get\_tags()](http://codex.wordpress.org/Function_Reference/get_tags) function. You would need to place it into the `single-post.php` (or `single.php` if your theme doesn't have a `single-post.php`) (to find the right template file you can always look up at [Wordpress Template Hierarc... |
152,301 | <p>Wordpress is loading all client resources of all plugins, not just the plugin of interest. It may make sense to load jqery globally but it makes no sense to load all other plugin's Javascript in a back-end plugin. </p>
<p>Now, how can I prevent that Wordpress is loading other plugin's resources? </p>
<p>There's w... | [
{
"answer_id": 182729,
"author": "redelschaap",
"author_id": 69725,
"author_profile": "https://wordpress.stackexchange.com/users/69725",
"pm_score": 0,
"selected": false,
"text": "<p>This is always a problem when using a plugin that loads extra css/js files. You could add custom fields t... | 2014/06/30 | [
"https://wordpress.stackexchange.com/questions/152301",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54967/"
] | Wordpress is loading all client resources of all plugins, not just the plugin of interest. It may make sense to load jqery globally but it makes no sense to load all other plugin's Javascript in a back-end plugin.
Now, how can I prevent that Wordpress is loading other plugin's resources?
There's wp\_dequeue but I a... | You could try echoing wp\_head and wp\_footer to see what they contain but unfortunately that'll miss stuff some of the authors hardcode. Basically what I do is wp\_dequeue/wp\_deregister based on what I see being loaded in either the source, error-logs or even just looking within each of the installed plugins to see w... |
152,306 | <p>I need to change my permalink structure just for one category. Now I have: <code>/%postname%/</code> , but for News category I need this structure: <code>/%postname%-%post_id%/</code>.</p>
<p><strong>Question:</strong> how to add %post_id% in specific category?</p>
| [
{
"answer_id": 152307,
"author": "s1lv3r",
"author_id": 27536,
"author_profile": "https://wordpress.stackexchange.com/users/27536",
"pm_score": 0,
"selected": false,
"text": "<p>If you want it only for one category I think the easiest way is to use <a href=\"http://codex.wordpress.org/Pl... | 2014/06/30 | [
"https://wordpress.stackexchange.com/questions/152306",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54970/"
] | I need to change my permalink structure just for one category. Now I have: `/%postname%/` , but for News category I need this structure: `/%postname%-%post_id%/`.
**Question:** how to add %post\_id% in specific category? | This can be accomplished with some custom filters & actions.
Try placing this code in your theme's functions.php file:
```
add_filter( 'post_link', 'custom_permalink', 10, 3 );
function custom_permalink( $permalink, $post, $leavename ) {
// Get the categories for the post
$category = get_the_category($post->... |
152,315 | <p>I am trying to install wordpress into a subdirectory of a website.</p>
<p>I simply want to build the client's new site in this subdirectory, so a separate and new WP install in this subdirectory, and then when complete, delete the current (old) site and move the new wp website from the subdirectory to the root.</p>... | [
{
"answer_id": 152307,
"author": "s1lv3r",
"author_id": 27536,
"author_profile": "https://wordpress.stackexchange.com/users/27536",
"pm_score": 0,
"selected": false,
"text": "<p>If you want it only for one category I think the easiest way is to use <a href=\"http://codex.wordpress.org/Pl... | 2014/07/01 | [
"https://wordpress.stackexchange.com/questions/152315",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54520/"
] | I am trying to install wordpress into a subdirectory of a website.
I simply want to build the client's new site in this subdirectory, so a separate and new WP install in this subdirectory, and then when complete, delete the current (old) site and move the new wp website from the subdirectory to the root.
I've uploade... | This can be accomplished with some custom filters & actions.
Try placing this code in your theme's functions.php file:
```
add_filter( 'post_link', 'custom_permalink', 10, 3 );
function custom_permalink( $permalink, $post, $leavename ) {
// Get the categories for the post
$category = get_the_category($post->... |
152,350 | <p>I'm trying to add a youtube button in TinyMce editor.</p>
<p>here is a recent-posts.js file which is in the js folder of the theme directory.</p>
<pre><code>(function() {
tinymce.create('tinymce.plugins.buttons', {
init : function(ed, url) {
//for recent post button
ed.addButton('recent... | [
{
"answer_id": 152355,
"author": "Matt Royal",
"author_id": 51860,
"author_profile": "https://wordpress.stackexchange.com/users/51860",
"pm_score": 4,
"selected": true,
"text": "<p>You wouldn't be able to add a FontAwesome icon by passing it directly to the <code>ed.addButton();</code> m... | 2014/07/01 | [
"https://wordpress.stackexchange.com/questions/152350",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51956/"
] | I'm trying to add a youtube button in TinyMce editor.
here is a recent-posts.js file which is in the js folder of the theme directory.
```
(function() {
tinymce.create('tinymce.plugins.buttons', {
init : function(ed, url) {
//for recent post button
ed.addButton('recentposts', {
... | You wouldn't be able to add a FontAwesome icon by passing it directly to the `ed.addButton();` method unfortunately.
You can try a workaround however. If you leave the `image : url+'/youtube.png'` parameter out of the method then it will automatically create an empty `<span>` with the class of `mceIcon` & another clas... |
152,366 | <p>I have a custom post type, with a custom field associated with it. I've setup a WP_Query to return all the posts of that post type. What I want to do is to show the first one that meets a unique criteria for the custom field, and not any subsequent ones.</p>
<p>As an example let's say I have 5 posts, and for those ... | [
{
"answer_id": 152376,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>This is more in the realm of basic PHP, which is often overlooked with WP's loop \"magic\".</p>\n\n<pre><code>$valu... | 2014/07/01 | [
"https://wordpress.stackexchange.com/questions/152366",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47334/"
] | I have a custom post type, with a custom field associated with it. I've setup a WP\_Query to return all the posts of that post type. What I want to do is to show the first one that meets a unique criteria for the custom field, and not any subsequent ones.
As an example let's say I have 5 posts, and for those 5 posts t... | Based on the comments I think I'd implement this outside of the query itself, and use PHP to filter the results. I'll give you a second solution as well, but I think this first one is easier to understand (when you come back to it later on).
Since I don't know the specifics of your code, here's a pseudocode approach.
... |
152,404 | <p>I'm trying to implement the code to add a custom post status from my plugin, exactly as given in this tutorial: <a href="http://jamescollings.co.uk/blog/wordpress-create-custom-post-status/" rel="nofollow">http://jamescollings.co.uk/blog/wordpress-create-custom-post-status/</a></p>
<p>Now, it isn't working and afte... | [
{
"answer_id": 152406,
"author": "Shazzad",
"author_id": 42967,
"author_profile": "https://wordpress.stackexchange.com/users/42967",
"pm_score": 1,
"selected": false,
"text": "<p>I thing you are missing the context. <code>$GLOBALS['hook_suffix']</code> is available on any action fired af... | 2014/07/01 | [
"https://wordpress.stackexchange.com/questions/152404",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/108/"
] | I'm trying to implement the code to add a custom post status from my plugin, exactly as given in this tutorial: <http://jamescollings.co.uk/blog/wordpress-create-custom-post-status/>
Now, it isn't working and after some investigation it seems the admin\_footer-post.php action isn't firing. The codex page for this acti... | I thing you are missing the context. `$GLOBALS['hook_suffix']` is available on any action fired after `admin_init`.
Now, if you tried something like `add_action( 'admin_footer-'. $GLOBALS['hook_suffix'], 'myfunction' )` outside of any function, you are not going to get anything.
But if you do it - `add_action('admi... |
152,429 | <p>Here's code I've modified to display an archive list of every month I've posted news. Each month of course links to the archive for that month. I can then include the shortcode wherever I like.</p>
<pre><code>function my_archives($params, $content = null) {
extract(shortcode_atts(array(
'type' => 'style1'
), $p... | [
{
"answer_id": 152424,
"author": "dipali",
"author_id": 20711,
"author_profile": "https://wordpress.stackexchange.com/users/20711",
"pm_score": 3,
"selected": true,
"text": "<p>You can display author's list by using function <code>wp_list_authors</code></p>\n\n<p>for more info : <a href=... | 2014/07/02 | [
"https://wordpress.stackexchange.com/questions/152429",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34465/"
] | Here's code I've modified to display an archive list of every month I've posted news. Each month of course links to the archive for that month. I can then include the shortcode wherever I like.
```
function my_archives($params, $content = null) {
extract(shortcode_atts(array(
'type' => 'style1'
), $params));
ob_star... | You can display author's list by using function `wp_list_authors`
for more info : <http://codex.wordpress.org/Function_Reference/wp_list_authors>
And for author Template Hierarchy see below link
<http://codex.wordpress.org/Author_Templates> |
152,466 | <p>I've got a multisite install in development where both the subdomains and the main site use the exact same page templates for showing data. However, when I try to get a profile image (added ID in wp_usermeta), I get <code>false</code> on the subdomains, but the actual image data returned on the main domain. </p>
<p... | [
{
"answer_id": 152467,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://queryposts.com/function/wp_get_attachment_image_src/\" rel=\"nofollow\"><code>wp_get_attachment_im... | 2014/07/02 | [
"https://wordpress.stackexchange.com/questions/152466",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25191/"
] | I've got a multisite install in development where both the subdomains and the main site use the exact same page templates for showing data. However, when I try to get a profile image (added ID in wp\_usermeta), I get `false` on the subdomains, but the actual image data returned on the main domain.
I came across that ... | Based on @Rarst his answer, I've created the following workaround.
An additional field `created_on` should be added to a users' metadata upon creation. This is to identify the subdomain the user was created on and where the profile image might reside. So add this to your code ;)
Place this function in a file where ... |
152,483 | <p>This issue seems to be quite common, but the solutions that worked for others haven't worked for me.</p>
<p>I'm using the CPT UI plugin and have created a CPT called 'courses' with the following settings:</p>
<pre><code>register_post_type('courses', array(
'label' => 'Courses',
'description' => '',
'public' ... | [
{
"answer_id": 152467,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://queryposts.com/function/wp_get_attachment_image_src/\" rel=\"nofollow\"><code>wp_get_attachment_im... | 2014/07/02 | [
"https://wordpress.stackexchange.com/questions/152483",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25430/"
] | This issue seems to be quite common, but the solutions that worked for others haven't worked for me.
I'm using the CPT UI plugin and have created a CPT called 'courses' with the following settings:
```
register_post_type('courses', array(
'label' => 'Courses',
'description' => '',
'public' => true,
'show_ui' => true,... | Based on @Rarst his answer, I've created the following workaround.
An additional field `created_on` should be added to a users' metadata upon creation. This is to identify the subdomain the user was created on and where the profile image might reside. So add this to your code ;)
Place this function in a file where ... |
152,510 | <p>I have a custom post type called email_block and have a custom taxonomy called block_type. I need to loop through all the email blocks find out what custom taxonomy (block_type) they have. I know how get all the email block custom post types, it's finding the what block_type they belong to is what I'm struggling wit... | [
{
"answer_id": 152513,
"author": "deflime",
"author_id": 18907,
"author_profile": "https://wordpress.stackexchange.com/users/18907",
"pm_score": 6,
"selected": true,
"text": "<p>You mean <a href=\"http://codex.wordpress.org/Function_Reference/get_the_terms\" rel=\"noreferrer\">get_the_te... | 2014/07/02 | [
"https://wordpress.stackexchange.com/questions/152510",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/55026/"
] | I have a custom post type called email\_block and have a custom taxonomy called block\_type. I need to loop through all the email blocks find out what custom taxonomy (block\_type) they have. I know how get all the email block custom post types, it's finding the what block\_type they belong to is what I'm struggling wi... | You mean [get\_the\_terms()](http://codex.wordpress.org/Function_Reference/get_the_terms)?
```
<?php
$terms = get_the_terms( $post->ID, 'block_type' );
foreach($terms as $term) {
echo $term->name;
}
?>
```
Or have I simplified this too much? |
152,518 | <p>Is there a action similar to save_post for comments? Already tried comment_post which does not fire when clicking the update button on a comment in WordPress.</p>
| [
{
"answer_id": 152520,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 2,
"selected": true,
"text": "<p>You can try the <code>edit_comment</code> hook that's fired within the <code>wp_update_comment()</code> functi... | 2014/07/02 | [
"https://wordpress.stackexchange.com/questions/152518",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47194/"
] | Is there a action similar to save\_post for comments? Already tried comment\_post which does not fire when clicking the update button on a comment in WordPress. | You can try the `edit_comment` hook that's fired within the `wp_update_comment()` function, called by the `edit_comment()` function when you edit a comment in the backend.
This hook is fired after the comment is updated in the database.
**Example:**
```
add_action( 'edit_comment',
function( $comment_ID )
{... |
152,528 | <p>I have the following shortcode:</p>
<pre><code>[video width="400" height="400" mp4="http://xxxx.xxxx.xxx/uploads/2014/06/Facebook.mp4"][/video]
</code></pre>
<p>I need to get every single atts a single variable, I mean, I need something like this</p>
<pre><code>$width = 400
$height = 400
$file = http://xxxx.xxxx.... | [
{
"answer_id": 152530,
"author": "John Blackbourn",
"author_id": 27051,
"author_profile": "https://wordpress.stackexchange.com/users/27051",
"pm_score": 3,
"selected": true,
"text": "<p>Straight from the <a href=\"https://codex.wordpress.org/Shortcode_API\" rel=\"nofollow\">Shortcode API... | 2014/07/02 | [
"https://wordpress.stackexchange.com/questions/152528",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54924/"
] | I have the following shortcode:
```
[video width="400" height="400" mp4="http://xxxx.xxxx.xxx/uploads/2014/06/Facebook.mp4"][/video]
```
I need to get every single atts a single variable, I mean, I need something like this
```
$width = 400
$height = 400
$file = http://xxxx.xxxx.xxx/uploads/2014/06/Facebook.mp4
```... | Straight from the [Shortcode API page on the Codex](https://codex.wordpress.org/Shortcode_API):
>
> The raw $atts array may include any arbitrary attributes that are specified by the user.
>
>
>
That is to say, the `$atts` parameter passed to your shortcode callback function contains all the attributes in an asso... |
152,548 | <p>I have a link in worpress page</p>
<pre><code><a onclick="show_trend()" >Trend</a>
</code></pre>
<p>and i am calling an ajax function onclick.</p>
<pre><code>function show_trend() {
// This does the ajax request
$.ajax({
url: ajaxurl,
data: {
'action':'render_admin... | [
{
"answer_id": 152551,
"author": "TBI Infotech",
"author_id": 52417,
"author_profile": "https://wordpress.stackexchange.com/users/52417",
"pm_score": 1,
"selected": false,
"text": "<p>To add action for Wordpress AJAX</p>\n\n<p>If you needed to create an AJAX handler for an \"render_admin... | 2014/07/03 | [
"https://wordpress.stackexchange.com/questions/152548",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52105/"
] | I have a link in worpress page
```
<a onclick="show_trend()" >Trend</a>
```
and i am calling an ajax function onclick.
```
function show_trend() {
// This does the ajax request
$.ajax({
url: ajaxurl,
data: {
'action':'render_admin_charts_page',
},
success:functi... | To add action for Wordpress AJAX
If you needed to create an AJAX handler for an "render\_admin\_charts\_page" request, you would create a hook like this:
```
add_action( 'wp_ajax_render_admin_charts_page', 'yourfunction' );
function yourfunction() { ?>
<div class="wrap">
<div class="em-bookings-events">
... |
152,558 | <p>i have two pages in my wordpress plugin</p>
<ul>
<li>index.php</li>
<li>charts.php</li>
</ul>
<p>in index.php i have some content and some link..</p>
<pre><code> <a onclick="show_trend()" >Trend</a>
</code></pre>
<p>while clicking this link ,i have an ajax function to create content in charts.php(i d... | [
{
"answer_id": 152567,
"author": "Hendrik Luehrsen",
"author_id": 38514,
"author_profile": "https://wordpress.stackexchange.com/users/38514",
"pm_score": 0,
"selected": false,
"text": "<p>As ungestaltbar said, the variable \"data\" should contain an object, not a string.</p>\n\n<pre><cod... | 2014/07/03 | [
"https://wordpress.stackexchange.com/questions/152558",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52105/"
] | i have two pages in my wordpress plugin
* index.php
* charts.php
in index.php i have some content and some link..
```
<a onclick="show_trend()" >Trend</a>
```
while clicking this link ,i have an ajax function to create content in charts.php(i dont know if it is correct way)
```
function show_trend() {
var data ... | I see two things. You're missing an action call - you need
```
add_action( 'wp_ajax_render_admin_charts_page', 'render_admin_charts_page' );
add_action('wp_ajax_nopriv_render_admin_charts_page', 'render_admin_charts_page');
```
Plus, from looking at your `render_admin_charts_page()` you need to change your json data... |
152,559 | <p>I have a few questions relating to WordPress loading / unloading up javascript tools. After reading a nicely written response to a question by Pieter Goosen, that got me to do a bit of studying and a clean up of the code I'm using to load up my libraries. This code is from my child-theme's function.php file. I've ... | [
{
"answer_id": 152565,
"author": "Hendrik Luehrsen",
"author_id": 38514,
"author_profile": "https://wordpress.stackexchange.com/users/38514",
"pm_score": 3,
"selected": true,
"text": "<p>Wordpress has essentially two groups of methods to handle scripts, both of which should be used: </p>... | 2014/07/03 | [
"https://wordpress.stackexchange.com/questions/152559",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45680/"
] | I have a few questions relating to WordPress loading / unloading up javascript tools. After reading a nicely written response to a question by Pieter Goosen, that got me to do a bit of studying and a clean up of the code I'm using to load up my libraries. This code is from my child-theme's function.php file. I've got a... | Wordpress has essentially two groups of methods to handle scripts, both of which should be used:
* `wp_register_script` Registers a script in Wordpress. It does not get called, it is just available for Wordpress, if it is needed.
* `wp_deregister_script` is the exact opposite. It deletes the definitions made in wp\_r... |
152,579 | <p>I want to create a simple plugin (already started) to have in one place recurring tasks (for me as webdesigner) e.g. take site offline, set backend icon, don't show updates and so on...</p>
<p>Now I want to hide some menus for my clients in BE and I am asking if someone knows a query to get all existing menus?</p>
... | [
{
"answer_id": 152565,
"author": "Hendrik Luehrsen",
"author_id": 38514,
"author_profile": "https://wordpress.stackexchange.com/users/38514",
"pm_score": 3,
"selected": true,
"text": "<p>Wordpress has essentially two groups of methods to handle scripts, both of which should be used: </p>... | 2014/07/03 | [
"https://wordpress.stackexchange.com/questions/152579",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/42681/"
] | I want to create a simple plugin (already started) to have in one place recurring tasks (for me as webdesigner) e.g. take site offline, set backend icon, don't show updates and so on...
Now I want to hide some menus for my clients in BE and I am asking if someone knows a query to get all existing menus?
Thanks in adv... | Wordpress has essentially two groups of methods to handle scripts, both of which should be used:
* `wp_register_script` Registers a script in Wordpress. It does not get called, it is just available for Wordpress, if it is needed.
* `wp_deregister_script` is the exact opposite. It deletes the definitions made in wp\_r... |
152,587 | <p>I have following format of menu.</p>
<pre><code>Treatment
-Beauty
--Services
--Products
-Surgery
-washing
</code></pre>
<p>I have followed follwed following link: <a href="http://www.wpbeginner.com/wp-tutorials/how-to-display-a-list-of-child-pages-for-a-parent-page-in-wordpress/" rel="nofollow">How to Displ... | [
{
"answer_id": 152589,
"author": "Zammuuz",
"author_id": 40999,
"author_profile": "https://wordpress.stackexchange.com/users/40999",
"pm_score": 3,
"selected": true,
"text": "<p>Add this code to your functions.php. An explanation of the code is given below.</p>\n<pre><code>function wpb_l... | 2014/07/03 | [
"https://wordpress.stackexchange.com/questions/152587",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45086/"
] | I have following format of menu.
```
Treatment
-Beauty
--Services
--Products
-Surgery
-washing
```
I have followed follwed following link: [How to Display a List of Child Pages For a Parent Page in WordPress](http://www.wpbeginner.com/wp-tutorials/how-to-display-a-list-of-child-pages-for-a-parent-page-in-word... | Add this code to your functions.php. An explanation of the code is given below.
```
function wpb_list_child_pages() {
global $post;
$id = ( is_page() && $post->post_parent ) ? $post->post_parent : $post->ID;
$childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $id . '&echo=0' );
... |
152,588 | <p>So I have the problem, the image I want to dispaly in post is not big enough and in my preffered size it gets bad quality, then i noticed that is not the default size image returned it's medium size and I tried to check but didn't find anything in particular.</p>
<pre><code>while ( have_posts() ) : the_post();
... | [
{
"answer_id": 152593,
"author": "user3535301",
"author_id": 55097,
"author_profile": "https://wordpress.stackexchange.com/users/55097",
"pm_score": 0,
"selected": false,
"text": "<p>Try to upload image from featured image option and to fetch it use the below code where you can set heigh... | 2014/07/03 | [
"https://wordpress.stackexchange.com/questions/152588",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/55096/"
] | So I have the problem, the image I want to dispaly in post is not big enough and in my preffered size it gets bad quality, then i noticed that is not the default size image returned it's medium size and I tried to check but didn't find anything in particular.
```
while ( have_posts() ) : the_post();
the_content();... | The UI might be slightly different depending on what version of WordPess you are running but just before you select the insert button/link, simply just select 'Full Size' size image from the dropdown menu.
 |
152,592 | <p><strong>Issue</strong>: I have the term_taxonomy_id, I do not have the taxonomy name, I want to retrieve the term object without doing a direct database query.</p>
<p><strong>Thoughts:</strong> Well the API docs for <a href="http://codex.wordpress.org/Function_Reference/get_term_by" rel="nofollow">get_term_by</a> s... | [
{
"answer_id": 152601,
"author": "mrwweb",
"author_id": 9844,
"author_profile": "https://wordpress.stackexchange.com/users/9844",
"pm_score": 2,
"selected": false,
"text": "<p>I was pretty sure of this, but the answer is—at least for now—a definitive no. There isn't an API call for it.</... | 2014/07/03 | [
"https://wordpress.stackexchange.com/questions/152592",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8756/"
] | **Issue**: I have the term\_taxonomy\_id, I do not have the taxonomy name, I want to retrieve the term object without doing a direct database query.
**Thoughts:** Well the API docs for [get\_term\_by](http://codex.wordpress.org/Function_Reference/get_term_by) say that taxonomy is required and the [wp\_term\_taxonomy t... | I was pretty sure of this, but the answer is—at least for now—a definitive no. There isn't an API call for it.
To double-check, I asked [core developer Andrew Nacin about this on Twitter](https://twitter.com/nacin/status/484727882640404481). His response:
>
> term\_taxonomy\_id is, for the moment, essentially privat... |
152,619 | <p>I'm working with a Taxonomy where the Terms have lengthy descriptions. It makes the Admin Panel look really ugly when WordPress tries to display these descriptions for 10 categories. I'm trying to figure out a way to limit the number of words or characters displayed in the Category / Term Description Column but I ca... | [
{
"answer_id": 152625,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 3,
"selected": true,
"text": "<p>Ok, I revisited this and revised my answer.. </p>\n\n<p>But like I said before:</p>\n\n<blockquote>\... | 2014/07/03 | [
"https://wordpress.stackexchange.com/questions/152619",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7355/"
] | I'm working with a Taxonomy where the Terms have lengthy descriptions. It makes the Admin Panel look really ugly when WordPress tries to display these descriptions for 10 categories. I'm trying to figure out a way to limit the number of words or characters displayed in the Category / Term Description Column but I canno... | Ok, I revisited this and revised my answer..
But like I said before:
>
> the hook you are (trying) to use won't/can't work for the purpose you are aiming for, simply because its only occurrence is in `class-wp-posts-list-table.php`, which nomen est omen is used to show the post list, the right place should be `clas... |
152,628 | <p>I've looked and have not found anything that works.</p>
<p>I am trying to include a shortcode in a menu item's 'Navigation Label'. Basically Iwould like to have a dynamic title displaying the user's name & avatar.</p>
<pre><code>[profilepicture round] [user_name]
</code></pre>
<p>Right now it's just spit back... | [
{
"answer_id": 213585,
"author": "khushbu shah",
"author_id": 86121,
"author_profile": "https://wordpress.stackexchange.com/users/86121",
"pm_score": 2,
"selected": false,
"text": "<p>First of all download 'Shortcodes in Menus' plugin and install/activate it.</p>\n\n<p>Then in theme's fu... | 2014/07/04 | [
"https://wordpress.stackexchange.com/questions/152628",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26895/"
] | I've looked and have not found anything that works.
I am trying to include a shortcode in a menu item's 'Navigation Label'. Basically Iwould like to have a dynamic title displaying the user's name & avatar.
```
[profilepicture round] [user_name]
```
Right now it's just spit back out since Wordpress Menus do not par... | Since WP 4.4.0 you can use the following:
```
add_filter('nav_menu_item_title', function ($title, $item, $args, $depth) {
return do_shortcode($title);
}, 10, 4);
``` |
152,633 | <p>If I want to <em>always</em> change the admin toolbar at the top of the page it's easy.</p>
<pre><code>add_action('admin_bar_menu', 'add_toolbar_items', 100);
function add_toolbar_items($admin_bar){
$admin_bar->add_menu( array(
'id' => 'my-item',
'title' => 'My Item',
'href' => '#',
... | [
{
"answer_id": 213585,
"author": "khushbu shah",
"author_id": 86121,
"author_profile": "https://wordpress.stackexchange.com/users/86121",
"pm_score": 2,
"selected": false,
"text": "<p>First of all download 'Shortcodes in Menus' plugin and install/activate it.</p>\n\n<p>Then in theme's fu... | 2014/07/04 | [
"https://wordpress.stackexchange.com/questions/152633",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6351/"
] | If I want to *always* change the admin toolbar at the top of the page it's easy.
```
add_action('admin_bar_menu', 'add_toolbar_items', 100);
function add_toolbar_items($admin_bar){
$admin_bar->add_menu( array(
'id' => 'my-item',
'title' => 'My Item',
'href' => '#',
'meta' => array(
'titl... | Since WP 4.4.0 you can use the following:
```
add_filter('nav_menu_item_title', function ($title, $item, $args, $depth) {
return do_shortcode($title);
}, 10, 4);
``` |
152,634 | <p>I have two pages, events.php from plugin1 index.php from plugin2. in events.php. I am including jquery for ajax loading</p>
<pre><code><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<a onclick="show_trend(<?php echo $event->output('#_EVENTID');?>)" &... | [
{
"answer_id": 213585,
"author": "khushbu shah",
"author_id": 86121,
"author_profile": "https://wordpress.stackexchange.com/users/86121",
"pm_score": 2,
"selected": false,
"text": "<p>First of all download 'Shortcodes in Menus' plugin and install/activate it.</p>\n\n<p>Then in theme's fu... | 2014/07/04 | [
"https://wordpress.stackexchange.com/questions/152634",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52105/"
] | I have two pages, events.php from plugin1 index.php from plugin2. in events.php. I am including jquery for ajax loading
```
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<a onclick="show_trend(<?php echo $event->output('#_EVENTID');?>)" >Trend</a>
```
This ajax load works f... | Since WP 4.4.0 you can use the following:
```
add_filter('nav_menu_item_title', function ($title, $item, $args, $depth) {
return do_shortcode($title);
}, 10, 4);
``` |
152,651 | <p>I have been searching for some configurations of .htaccess, filters and hooks to make able to manage the inner site uri's. The goal was force login, register and admin pages through SSL, and all the other pages through HTTP.</p>
<p>Although it can be easy when you have the same domain for both, http and https, it c... | [
{
"answer_id": 213585,
"author": "khushbu shah",
"author_id": 86121,
"author_profile": "https://wordpress.stackexchange.com/users/86121",
"pm_score": 2,
"selected": false,
"text": "<p>First of all download 'Shortcodes in Menus' plugin and install/activate it.</p>\n\n<p>Then in theme's fu... | 2014/07/04 | [
"https://wordpress.stackexchange.com/questions/152651",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/55124/"
] | I have been searching for some configurations of .htaccess, filters and hooks to make able to manage the inner site uri's. The goal was force login, register and admin pages through SSL, and all the other pages through HTTP.
Although it can be easy when you have the same domain for both, http and https, it could be qu... | Since WP 4.4.0 you can use the following:
```
add_filter('nav_menu_item_title', function ($title, $item, $args, $depth) {
return do_shortcode($title);
}, 10, 4);
``` |