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 |
|---|---|---|---|---|---|---|
110,851 | <p>I'm not really that much of a jQuery aficionado so I'm not really sure why this little jQuery modal lightbox snippet isn't working.</p>
<p>Am I missing any kind of WP specific code?</p>
<p>I'm enqueueing the script in the header if that helps</p>
<pre><code>$(window).load(function(){
var lightBox = $('#lightb... | [
{
"answer_id": 110852,
"author": "Anjum",
"author_id": 3311,
"author_profile": "https://wordpress.stackexchange.com/users/3311",
"pm_score": 4,
"selected": true,
"text": "<p>the problem was in your variable define syntax and also you need to wrap your jQuery script into <a href=\"http://... | 2013/08/20 | [
"https://wordpress.stackexchange.com/questions/110851",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33310/"
] | I'm not really that much of a jQuery aficionado so I'm not really sure why this little jQuery modal lightbox snippet isn't working.
Am I missing any kind of WP specific code?
I'm enqueueing the script in the header if that helps
```
$(window).load(function(){
var lightBox = $('#lightbox'),
lightBoxContent = ... | the problem was in your variable define syntax and also you need to wrap your jQuery script into [no conflict](http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_Wrappers) wrapper, try this
```
jQuery(window).load(function($) {
// your function
});
```
or
```
(function($) {
// yo... |
110,862 | <p>I am trying to output a list of stockists in two columns from left to right, sorted alphabetically:</p>
<p>A | B</p>
<p>C | D</p>
<p>E | F</p>
<p>G | H</p>
<p>Currently, the code below is sorting half the posts alphabeticly and then starting half way through with the rest alphabeticly:</p>
<p>A | C</p>
<p>E |... | [
{
"answer_id": 110852,
"author": "Anjum",
"author_id": 3311,
"author_profile": "https://wordpress.stackexchange.com/users/3311",
"pm_score": 4,
"selected": true,
"text": "<p>the problem was in your variable define syntax and also you need to wrap your jQuery script into <a href=\"http://... | 2013/08/20 | [
"https://wordpress.stackexchange.com/questions/110862",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36867/"
] | I am trying to output a list of stockists in two columns from left to right, sorted alphabetically:
A | B
C | D
E | F
G | H
Currently, the code below is sorting half the posts alphabeticly and then starting half way through with the rest alphabeticly:
A | C
E | G
B | D
F | H
Any idea on where I am going wrong... | the problem was in your variable define syntax and also you need to wrap your jQuery script into [no conflict](http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_Wrappers) wrapper, try this
```
jQuery(window).load(function($) {
// your function
});
```
or
```
(function($) {
// yo... |
110,866 | <p>Below is my <strong>single.php</strong> page's code:</p>
<pre><code> <?php while ( have_posts() ) : the_post(); ?>
<h3>
<?php the_title(); ?>
</h3>
<?php
if ( in_category( 'salon' ) ) {
get_template_part( 'content', 'salon' );
}
if ( in_category( 'staff' ... | [
{
"answer_id": 110869,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 2,
"selected": false,
"text": "<p>First of all, please don't use query posts, you're storing up a whole world of pain: <a href=\"https://w... | 2013/08/20 | [
"https://wordpress.stackexchange.com/questions/110866",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16755/"
] | Below is my **single.php** page's code:
```
<?php while ( have_posts() ) : the_post(); ?>
<h3>
<?php the_title(); ?>
</h3>
<?php
if ( in_category( 'salon' ) ) {
get_template_part( 'content', 'salon' );
}
if ( in_category( 'staff' ) ) {
get_template_part( 'content', 'staff' )... | Here is solution...please try this stuff......
```
<?php
/**
* The template for displaying all pages.
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages
* and that other 'pages' on your WordPress site will use a
* different template.
*
* @pa... |
110,875 | <p>wrote this piece of code to make a alphabetical glossary and it works, but there is 1 problem. I don't know how I can end a set of posts with the same first letter. </p>
<p>This code looks at the first letter of the second word (this is for my project) and then it makes a heading with that first letter and places a... | [
{
"answer_id": 110884,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>If you search the site, most of the \"display nth post different\" questions are very closely related to this... | 2013/08/20 | [
"https://wordpress.stackexchange.com/questions/110875",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25834/"
] | wrote this piece of code to make a alphabetical glossary and it works, but there is 1 problem. I don't know how I can end a set of posts with the same first letter.
This code looks at the first letter of the second word (this is for my project) and then it makes a heading with that first letter and places all the mat... | If you search the site, most of the "display nth post different" questions are very closely related to this one, and honestly this is more a PHP + logic question that a WordPress one.
```
if (have_posts()) {
$curr_letter = '';
echo '<div class="alphawrapper">';
while (have_posts()) {
the_post();
... |
110,883 | <p>I have created a special role in WP admin and now I would like to allow to login to certain frontend page only people with this role. How to do that? I still want be able to login for all people for other areas.</p>
| [
{
"answer_id": 110884,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>If you search the site, most of the \"display nth post different\" questions are very closely related to this... | 2013/08/20 | [
"https://wordpress.stackexchange.com/questions/110883",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17368/"
] | I have created a special role in WP admin and now I would like to allow to login to certain frontend page only people with this role. How to do that? I still want be able to login for all people for other areas. | If you search the site, most of the "display nth post different" questions are very closely related to this one, and honestly this is more a PHP + logic question that a WordPress one.
```
if (have_posts()) {
$curr_letter = '';
echo '<div class="alphawrapper">';
while (have_posts()) {
the_post();
... |
110,886 | <p>I'm using a plugin that will display content based on user location, and I'm trying to add it to a facebook widget code. The plugin is using a shortcode to wrap content that will be displayed, and here is what I have so far. I know I'm doing something wrong, and would really appreciate it if you can point me to the ... | [
{
"answer_id": 110897,
"author": "epilektric",
"author_id": 36634,
"author_profile": "https://wordpress.stackexchange.com/users/36634",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/do_shortcode#Examples\" rel=\"nofollow\">From Code... | 2013/08/20 | [
"https://wordpress.stackexchange.com/questions/110886",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36874/"
] | I'm using a plugin that will display content based on user location, and I'm trying to add it to a facebook widget code. The plugin is using a shortcode to wrap content that will be displayed, and here is what I have so far. I know I'm doing something wrong, and would really appreciate it if you can point me to the rig... | [From Codex Shortcode Examples](http://codex.wordpress.org/Function_Reference/do_shortcode#Examples)
>
> // In case there is opening and closing shortcode.
>
> echo do\_shortcode('[iscorrect]'.$text\_to\_be\_wrapped\_in\_shortcode.'[/iscorrect]');
>
>
>
Basically, you can't use `do_shortcode()` two separate ... |
110,895 | <p>im having troubles getting my custom stylesheet work on WP-ADMIN area.
<code>plugins_url('style.css', __FILE__) );</code> do i have to create folder in my plugins named css or do i just copy my <code>.css</code> to the <code>wp-admin/css</code> directory? </p>
<p>i tried both it doesnt seem to work for me.</p>
<p>... | [
{
"answer_id": 110899,
"author": "iEmanuele",
"author_id": 35646,
"author_profile": "https://wordpress.stackexchange.com/users/35646",
"pm_score": 7,
"selected": true,
"text": "<p>According to WordPress Codex (<a href=\"http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue... | 2013/08/20 | [
"https://wordpress.stackexchange.com/questions/110895",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25549/"
] | im having troubles getting my custom stylesheet work on WP-ADMIN area.
`plugins_url('style.css', __FILE__) );` do i have to create folder in my plugins named css or do i just copy my `.css` to the `wp-admin/css` directory?
i tried both it doesnt seem to work for me.
and what values should be replaced to `__FILE__`?
... | According to WordPress Codex ([here](http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts)):
>
> **admin\_enqueue\_scripts** is the first action hooked into the admin
> scripts actions.
>
>
>
**Example**
Loading a CSS or JS files for all admin area:
```php
//from functions.php
//First s... |
110,912 | <p>I'm trying to add masonry sript to my site, but <code>wp_enqueue_script('jquery-masonry');</code> is not adding the script.</p>
<p>Instead I have to use: </p>
<pre><code>wp_register_script('jquery_masonry', includes_url(). '/js/jquery/jquery.masonry.min.js', 'jquery');
wp_enqueue_script('jquery_masonry');
</code><... | [
{
"answer_id": 110921,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>jQuery's Masonry is <a href=\"http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Default_Script... | 2013/08/20 | [
"https://wordpress.stackexchange.com/questions/110912",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1447/"
] | I'm trying to add masonry sript to my site, but `wp_enqueue_script('jquery-masonry');` is not adding the script.
Instead I have to use:
```
wp_register_script('jquery_masonry', includes_url(). '/js/jquery/jquery.masonry.min.js', 'jquery');
wp_enqueue_script('jquery_masonry');
```
Why is that? | jQuery's Masonry is [bundled with WordPress](http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Default_Scripts_Included_and_Registered_by_WordPress). All you should need is `wp_enqueue_script('jquery-masonry');` but note that the "slug" is `jquery-masonry`, not `jquery_masonry`. And be sure your are enque... |
110,925 | <p>I've been breaking my head over this for days now and can't seem to figure it out (with the limited knowledge I have). I want to achieve the following:</p>
<p>I have a custom post type 'Events'. Each event can take place multiple times per year, so I have custom fields for the dates, let's say 'dateA', 'dateB', 'da... | [
{
"answer_id": 110921,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>jQuery's Masonry is <a href=\"http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Default_Script... | 2013/08/20 | [
"https://wordpress.stackexchange.com/questions/110925",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36890/"
] | I've been breaking my head over this for days now and can't seem to figure it out (with the limited knowledge I have). I want to achieve the following:
I have a custom post type 'Events'. Each event can take place multiple times per year, so I have custom fields for the dates, let's say 'dateA', 'dateB', 'dateC'. I wa... | jQuery's Masonry is [bundled with WordPress](http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Default_Scripts_Included_and_Registered_by_WordPress). All you should need is `wp_enqueue_script('jquery-masonry');` but note that the "slug" is `jquery-masonry`, not `jquery_masonry`. And be sure your are enque... |
110,929 | <p>I ran into this when attempting to integrate Dropbox's <a href="https://www.dropbox.com/developers/dropins/chooser/js">drop in chooser API</a> to a plugin I'm writing.</p>
<p>The API documentation instructs you to place the following <code>script</code> tag at the top of your file:</p>
<pre><code><script type="... | [
{
"answer_id": 111440,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 2,
"selected": false,
"text": "<p>OK, it seems (to me) that with <code>wp_enqueque_scripts</code> is not <strong>possible</strong> to print the... | 2013/08/20 | [
"https://wordpress.stackexchange.com/questions/110929",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17879/"
] | I ran into this when attempting to integrate Dropbox's [drop in chooser API](https://www.dropbox.com/developers/dropins/chooser/js) to a plugin I'm writing.
The API documentation instructs you to place the following `script` tag at the top of your file:
```
<script type="text/javascript" src="https://www.dropbox.com/... | you can try to use the `script_loader_src` filter hook e.g:
```
add_filter('script_loader_src','add_id_to_script',10,2);
function add_id_to_script($src, $handle){
if ($handle != 'dropbox.js')
return $src;
return $src."' id='dropboxjs' data-app-key='MY_APP_KEY";
}
```
**Update**
i just figured i... |
110,931 | <p>Specifically, I am bringing back the 7 most recent posts in Category A, but then I want to put the first posts thumbnail in <code><div id=A></code> and the second post's thumbnail in <code><div id=B></code> and so on for the seven posts.</p>
<p>If this was an array, I would simply use the array position... | [
{
"answer_id": 110934,
"author": "GhostToast",
"author_id": 13676,
"author_profile": "https://wordpress.stackexchange.com/users/13676",
"pm_score": 1,
"selected": true,
"text": "<p>Why not just use a counter and then conditional logic?</p>\n\n<pre><code>$i = 0;\nwhile($loop->have_post... | 2013/08/20 | [
"https://wordpress.stackexchange.com/questions/110931",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36892/"
] | Specifically, I am bringing back the 7 most recent posts in Category A, but then I want to put the first posts thumbnail in `<div id=A>` and the second post's thumbnail in `<div id=B>` and so on for the seven posts.
If this was an array, I would simply use the array position inside of the `<div>`, but I'm not sure how... | Why not just use a counter and then conditional logic?
```
$i = 0;
while($loop->have_posts()) : $loop->the_post();
if($i === 0){
echo '<div class="a">'.other_stuff().'</div>';
} elseif($i === 1){
echo '<div class="b">'.other_stuff().'</div>';
} else {
echo '<div class="default">'.ot... |
110,948 | <p>I'm using the Advanced Custom Field (ACF) plugin in a Custom Post Type (CPT).</p>
<p>I have field group in ACF that contains a Image field and true/false field called 'home_offer'.</p>
<p>I'm using this ACF in a Custom Post Type called Offers.</p>
<p>I want to loop through the CPT Offers and check if the true/fal... | [
{
"answer_id": 110950,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 3,
"selected": true,
"text": "<p>First of all, <code>'post_per_page' => 1</code> in your code is wrong, right name of the argument is <stron... | 2013/08/20 | [
"https://wordpress.stackexchange.com/questions/110948",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31546/"
] | I'm using the Advanced Custom Field (ACF) plugin in a Custom Post Type (CPT).
I have field group in ACF that contains a Image field and true/false field called 'home\_offer'.
I'm using this ACF in a Custom Post Type called Offers.
I want to loop through the CPT Offers and check if the true/false field 'home\_offer' ... | First of all, `'post_per_page' => 1` in your code is wrong, right name of the argument is **posts\_per\_page** (note the plural in postS\_per\_page)
then if you want query for a 'true/false' field in ACF you have to use
```
'meta_query' => array(
array(
'key' => 'home_offer',
'value' => '1',
'compare' ... |
110,953 | <p>I'm trying to put a widget as "first post" if it's active.. and let the posts continue after that.. It works, but the first post disappears and the second post becomes the first in line after the widget.. Can't see what i'm doing wrong..</p>
<p>I already have a widget that shows in between the posts as you can see.... | [
{
"answer_id": 110950,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 3,
"selected": true,
"text": "<p>First of all, <code>'post_per_page' => 1</code> in your code is wrong, right name of the argument is <stron... | 2013/08/20 | [
"https://wordpress.stackexchange.com/questions/110953",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5778/"
] | I'm trying to put a widget as "first post" if it's active.. and let the posts continue after that.. It works, but the first post disappears and the second post becomes the first in line after the widget.. Can't see what i'm doing wrong..
I already have a widget that shows in between the posts as you can see.
```
<?ph... | First of all, `'post_per_page' => 1` in your code is wrong, right name of the argument is **posts\_per\_page** (note the plural in postS\_per\_page)
then if you want query for a 'true/false' field in ACF you have to use
```
'meta_query' => array(
array(
'key' => 'home_offer',
'value' => '1',
'compare' ... |
110,982 | <p>I'm using this function from <a href="https://wordpress.stackexchange.com/questions/9394/getting-all-values-for-a-custom-field-key-cross-post">this accepted</a> answer, which gets all values for a custom field key (cross-post).</p>
<p>How could it be modified to allow an array of post statuses?</p>
<pre><code>func... | [
{
"answer_id": 110985,
"author": "Kumar",
"author_id": 32466,
"author_profile": "https://wordpress.stackexchange.com/users/32466",
"pm_score": -1,
"selected": false,
"text": "<p>Instead of taking status as an array take it as a string in query like </p>\n\n<pre><code>function get_meta_va... | 2013/08/21 | [
"https://wordpress.stackexchange.com/questions/110982",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4999/"
] | I'm using this function from [this accepted](https://wordpress.stackexchange.com/questions/9394/getting-all-values-for-a-custom-field-key-cross-post) answer, which gets all values for a custom field key (cross-post).
How could it be modified to allow an array of post statuses?
```
function get_meta_values( $key = '',... | Just implode the passed array:
```
function get_meta_values( $key = '', $type = 'post', $status = array( 'publish', 'draft' ) ) {
global $wpdb;
if( empty( $key ) )
return;
//First escape the status, since we don't use it with $wpdb->prepare()
$status = esc_sql( $status );
//If its an... |
111,015 | <p>Are there any best practices for wordpress hardened install on Linux? I have recently had a WAMP server get malware attacked via word press so I want to harden the server up using read only apache permissions and move them and all future wordpress sites to Linux only</p>
<p>the plan:</p>
<ol>
<li>chown everything ... | [
{
"answer_id": 111038,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n<p>... can you tell me which bits of auto-updatedness wordpress is likely to need?</p>\n</blockqu... | 2013/08/21 | [
"https://wordpress.stackexchange.com/questions/111015",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36925/"
] | Are there any best practices for wordpress hardened install on Linux? I have recently had a WAMP server get malware attacked via word press so I want to harden the server up using read only apache permissions and move them and all future wordpress sites to Linux only
the plan:
1. chown everything root:root -R so that... | **Heavily edited from the above link**
**How to Harden your Word Press if you're a server admin**
Bear in mind I am not an expert on Word Press nor even a user of it: you will probably not be able to automatically self update word press (which is by default a *massive* security issue since vulnerabilities today are p... |
111,017 | <p>The reason why I ask such a question isn't because I don't know how to do so at all, but rather I think the way I've trying to go about it may be wrong and that I don't understand how wordpress works well enough to know what is the best way to add functionality and custom fields to an existing theme.</p>
<p>For exa... | [
{
"answer_id": 111028,
"author": "JMau",
"author_id": 31376,
"author_profile": "https://wordpress.stackexchange.com/users/31376",
"pm_score": 0,
"selected": false,
"text": "<p>First, you clearly understand the purpose of child theme : <strong>easier maintenance</strong>, <strong>speed up... | 2013/08/21 | [
"https://wordpress.stackexchange.com/questions/111017",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36926/"
] | The reason why I ask such a question isn't because I don't know how to do so at all, but rather I think the way I've trying to go about it may be wrong and that I don't understand how wordpress works well enough to know what is the best way to add functionality and custom fields to an existing theme.
For example I hav... | You also have a functions.php file which is really powerful in your child theme. You can override main theme functions, add new features - whatever you want. First thing I do in my child theme (usually) is add my google verification code.
```
function lmc_do_meta_tags(){
echo "<meta name=\"google-site-verification\" c... |
111,032 | <p>Context: Creating a MultiSite in which each Sub-Site will have it's own set of users that they belong to. These users are only able to view their own site.</p>
<p>I was wondering what the easiest way to mass-email the users of each Sub-Site would be? For instance, when a new News post is put in the blog, it will se... | [
{
"answer_id": 111028,
"author": "JMau",
"author_id": 31376,
"author_profile": "https://wordpress.stackexchange.com/users/31376",
"pm_score": 0,
"selected": false,
"text": "<p>First, you clearly understand the purpose of child theme : <strong>easier maintenance</strong>, <strong>speed up... | 2013/08/21 | [
"https://wordpress.stackexchange.com/questions/111032",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36618/"
] | Context: Creating a MultiSite in which each Sub-Site will have it's own set of users that they belong to. These users are only able to view their own site.
I was wondering what the easiest way to mass-email the users of each Sub-Site would be? For instance, when a new News post is put in the blog, it will send a notif... | You also have a functions.php file which is really powerful in your child theme. You can override main theme functions, add new features - whatever you want. First thing I do in my child theme (usually) is add my google verification code.
```
function lmc_do_meta_tags(){
echo "<meta name=\"google-site-verification\" c... |
111,033 | <p>I'm looking for a way to create an overview page for taxonomies. So say you're on a page for a certain page (domain.com/my_tax/myterm) it would show different content types in the 'myterm' category. Posts, Pages, and a Custom Content types. All of which are pulled through taxonomy.php.</p>
<p>I can get this working... | [
{
"answer_id": 111036,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 1,
"selected": false,
"text": "<p>When you use a link like <code>domain.com/my_tax/myterm</code> this is called 'Taxonomy Archive' and is handl... | 2013/08/21 | [
"https://wordpress.stackexchange.com/questions/111033",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36930/"
] | I'm looking for a way to create an overview page for taxonomies. So say you're on a page for a certain page (domain.com/my\_tax/myterm) it would show different content types in the 'myterm' category. Posts, Pages, and a Custom Content types. All of which are pulled through taxonomy.php.
I can get this working fine, bu... | If all you're trying to do is to **display all post types on the taxonomy archive**, then you can easily accomplish that by filtering the query at `pre_get_posts`. Assuming a taxonomy `foobar`:
```
function wpse111033_filter_pre_get_posts( $query ) {
if ( $query->is_main_query() && $query->is_tax( 'foobar' ) ) {
... |
111,060 | <p>I am currently am working on a custom theme. In this theme, I have a menu that I registered using <code>register-nav-menu</code>, and then I am displaying the menu to my web page using the <code>wp_nav_menu</code> function.</p>
<p>However, I like to retrieve the list of menu items only (the actual menu item names o... | [
{
"answer_id": 111061,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 5,
"selected": true,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items\" rel=\"noreferrer\">wp_get_nav... | 2013/08/21 | [
"https://wordpress.stackexchange.com/questions/111060",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34253/"
] | I am currently am working on a custom theme. In this theme, I have a menu that I registered using `register-nav-menu`, and then I am displaying the menu to my web page using the `wp_nav_menu` function.
However, I like to retrieve the list of menu items only (the actual menu item names only that were used in wp-admin a... | [wp\_get\_nav\_menu\_items](http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items) would appear to be exactly what you require. It returns an array of menu objects. |
111,066 | <p>Is there a way to return single values only when I run</p>
<pre><code>get_post_custom($post_id);
</code></pre>
<p>it seems that I'm receiving double array, even when there only one value for this meta_key</p>
| [
{
"answer_id": 111069,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 1,
"selected": false,
"text": "<pre><code>// change the meta key and note the last true\nget_post_meta($post_id, 'your_meta_key_goes_here', tru... | 2013/08/21 | [
"https://wordpress.stackexchange.com/questions/111066",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29295/"
] | Is there a way to return single values only when I run
```
get_post_custom($post_id);
```
it seems that I'm receiving double array, even when there only one value for this meta\_key | this is what I've done to achieve this, it will return single dimension array when single results are found, and bi-dimensional array when multiple results are found
```
/*
* Get post custom Single (in functions.php)
*/
function get_post_custom_single($post_id) {
$metas = get_post_custom($post_id);
foreach($me... |
111,070 | <p>Here's an interesting question. I am trying to format previous and next links using the following format</p>
<pre><code> <?php previous_post_link('<strong>«</strong>'); ?>
<?php next_post_link('<strong>»</strong>'); ?>
</code></pre>
<p>I did this on purpose to not display ... | [
{
"answer_id": 111078,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 1,
"selected": false,
"text": "<p>See <a href=\"http://codex.wordpress.org/Function_Reference/previous_post_link\" rel=\"nofollow\">the codex<... | 2013/08/21 | [
"https://wordpress.stackexchange.com/questions/111070",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/21245/"
] | Here's an interesting question. I am trying to format previous and next links using the following format
```
<?php previous_post_link('<strong>«</strong>'); ?>
<?php next_post_link('<strong>»</strong>'); ?>
```
I did this on purpose to not display the post title and make users need to click the arrows in to m... | See [the codex](http://codex.wordpress.org/Function_Reference/previous_post_link). The first parameter is format, the second is link text.
```
<?php previous_post_link('<strong>%link</strong>', '«'); ?>
<?php next_post_link('<strong>%link</strong>', '»'); ?>
``` |
111,096 | <p>here is my problem. It's been around 2 hours that I try to have a page listing all projects (they are a Custom Post Type) so I'm trying to have an archive file named archive-projects.php but when I try to access it with /projects/ , it redirects me to the home.php instead of a 404 error. I'm kinda lost there.
This i... | [
{
"answer_id": 111098,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 5,
"selected": true,
"text": "<p>Flush your permalinks - by which I mean simply visit the Permalinks page under Settings.</p>\n\n<p>Then check... | 2013/08/21 | [
"https://wordpress.stackexchange.com/questions/111096",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36947/"
] | here is my problem. It's been around 2 hours that I try to have a page listing all projects (they are a Custom Post Type) so I'm trying to have an archive file named archive-projects.php but when I try to access it with /projects/ , it redirects me to the home.php instead of a 404 error. I'm kinda lost there.
This is m... | Flush your permalinks - by which I mean simply visit the Permalinks page under Settings.
Then check /projects again.
EDIT:
Remove
```
'publicly_queryable' => false,
```
from your arguments. It prevents rewrites. |
111,117 | <p>For some reason the following code is not displaying correctly on the frontend of my site - </p>
<pre><code><?php printf( esc_attr__( 'About %s', 'textdomain' ), the_author_posts_link() ); ?>
</code></pre>
<p>Instead of displaying the translatable string 'About' before the author's name/link, it's displaying... | [
{
"answer_id": 111098,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 5,
"selected": true,
"text": "<p>Flush your permalinks - by which I mean simply visit the Permalinks page under Settings.</p>\n\n<p>Then check... | 2013/08/22 | [
"https://wordpress.stackexchange.com/questions/111117",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34884/"
] | For some reason the following code is not displaying correctly on the frontend of my site -
```
<?php printf( esc_attr__( 'About %s', 'textdomain' ), the_author_posts_link() ); ?>
```
Instead of displaying the translatable string 'About' before the author's name/link, it's displaying it afterwards. I assume this is... | Flush your permalinks - by which I mean simply visit the Permalinks page under Settings.
Then check /projects again.
EDIT:
Remove
```
'publicly_queryable' => false,
```
from your arguments. It prevents rewrites. |
111,142 | <p>I am registering a custom post type like: </p>
<pre><code>/* POST TYPE: SECRET CARDS */
function register_post_type_secret_cards()
{
$args = array(
'labels' => array(
'name' => 'Secret Cards',
'singular_name' => 'Secret Card',
'add_new... | [
{
"answer_id": 111145,
"author": "Marcel",
"author_id": 36970,
"author_profile": "https://wordpress.stackexchange.com/users/36970",
"pm_score": 0,
"selected": false,
"text": "<p>If I understand your question correctly, just don't publish the post. On the top right in the post edit sectio... | 2013/08/22 | [
"https://wordpress.stackexchange.com/questions/111142",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17368/"
] | I am registering a custom post type like:
```
/* POST TYPE: SECRET CARDS */
function register_post_type_secret_cards()
{
$args = array(
'labels' => array(
'name' => 'Secret Cards',
'singular_name' => 'Secret Card',
'add_new' => 'Add New Item',
... | I think setting `'publicly_queryable' => false` should solve your problem! |
111,150 | <p>I was trying to add one more callback function to the WordPress AJAX action <code>woocommerce_apply_coupon</code>.</p>
<p>This action is defined in the WooCommerce plugin, I want to add my own callback function to this action from my plugin file.</p>
<p>What I have tried:</p>
<pre><code>add_action( 'wp_ajax_nopri... | [
{
"answer_id": 111166,
"author": "Michal Mau",
"author_id": 2110,
"author_profile": "https://wordpress.stackexchange.com/users/2110",
"pm_score": 3,
"selected": true,
"text": "<p>Yes. It is possible and you're on the right track! :)</p>\n\n<p><strong>AJAX calls happen \"behind the scenes... | 2013/08/22 | [
"https://wordpress.stackexchange.com/questions/111150",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36972/"
] | I was trying to add one more callback function to the WordPress AJAX action `woocommerce_apply_coupon`.
This action is defined in the WooCommerce plugin, I want to add my own callback function to this action from my plugin file.
What I have tried:
```
add_action( 'wp_ajax_nopriv_woocommerce_apply_coupon','darn',999)... | Yes. It is possible and you're on the right track! :)
**AJAX calls happen "behind the scenes"** and no screen output is generated during the process no matter what you `echo` or `print_r` - that's why you don't see anything returned to you - instead that server response is captured by javascript and acted upon there. ... |
111,167 | <p>I've got a custom post type <code>curiculum</code> and a metabox that saves a value to a custom field. However this custom field is added to another custom post type (created by an e-commerce plugin) <code>wpsc-product</code>.</p>
<p>This is a snippet of the code that deals with the metabox. The question is, how to... | [
{
"answer_id": 111166,
"author": "Michal Mau",
"author_id": 2110,
"author_profile": "https://wordpress.stackexchange.com/users/2110",
"pm_score": 3,
"selected": true,
"text": "<p>Yes. It is possible and you're on the right track! :)</p>\n\n<p><strong>AJAX calls happen \"behind the scenes... | 2013/08/22 | [
"https://wordpress.stackexchange.com/questions/111167",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20906/"
] | I've got a custom post type `curiculum` and a metabox that saves a value to a custom field. However this custom field is added to another custom post type (created by an e-commerce plugin) `wpsc-product`.
This is a snippet of the code that deals with the metabox. The question is, how to prevent the custom field being ... | Yes. It is possible and you're on the right track! :)
**AJAX calls happen "behind the scenes"** and no screen output is generated during the process no matter what you `echo` or `print_r` - that's why you don't see anything returned to you - instead that server response is captured by javascript and acted upon there. ... |
111,183 | <p>I have a client site which accepts images from users as posts. For moderation, we are opening each draft post which obviously takes a lot of time if a hefty amount of images are moderated.</p>
<p>So, Is there a way to show featured images of the post on the admin post list page as a column?</p>
| [
{
"answer_id": 111188,
"author": "jnthnclrk",
"author_id": 1341,
"author_profile": "https://wordpress.stackexchange.com/users/1341",
"pm_score": 5,
"selected": true,
"text": "<p>This is what I'm using, cobbled together from snippets found online... It's uses a filter on <code>manage_post... | 2013/08/22 | [
"https://wordpress.stackexchange.com/questions/111183",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23717/"
] | I have a client site which accepts images from users as posts. For moderation, we are opening each draft post which obviously takes a lot of time if a hefty amount of images are moderated.
So, Is there a way to show featured images of the post on the admin post list page as a column? | This is what I'm using, cobbled together from snippets found online... It's uses a filter on `manage_posts_colummns` to re-jig the headers and an action on `manage_posts_custom_column` to add the row level data.
```
function custom_columns( $columns ) {
$columns = array(
'cb' => '<input type="checkbox" />'... |
111,185 | <p>I've been playing around with code snippets which add meta data to admin searches.</p>
<p>The best snippet I've found was written by <a href="https://wordpress.stackexchange.com/questions/11758/extending-the-search-context-in-the-admin-list-post-screen">Stefano on this question</a>.</p>
<p>However, it appears to h... | [
{
"answer_id": 111538,
"author": "epilektric",
"author_id": 36634,
"author_profile": "https://wordpress.stackexchange.com/users/36634",
"pm_score": 5,
"selected": true,
"text": "<p>A <code>GROUP BY</code> statement can group your posts after the <code>JOIN</code>. For Wordpress you can u... | 2013/08/22 | [
"https://wordpress.stackexchange.com/questions/111185",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1341/"
] | I've been playing around with code snippets which add meta data to admin searches.
The best snippet I've found was written by [Stefano on this question](https://wordpress.stackexchange.com/questions/11758/extending-the-search-context-in-the-admin-list-post-screen).
However, it appears to have 1, annoying bug when sea... | A `GROUP BY` statement can group your posts after the `JOIN`. For Wordpress you can use the [`posts_groupby`](http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_groupby) filter.
```
add_filter( 'posts_groupby', 'my_post_limits' );
function my_post_limits($groupby) {
global $pagenow, $wpdb;
if ( is_ad... |
111,190 | <p>The Twenty Thirteen theme uses Bitter for headings and Source Sans Pro for body text. I would like to change these.</p>
<p>The fonts are included by the line:</p>
<pre><code><link rel='stylesheet' id='twentythirteen-fonts-css' href='//fonts.googleapis.com/css?family=Source+Sans+Pro%3A300%2C400%2C700%2C300itali... | [
{
"answer_id": 111195,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>I looked at TwentyThirteen's <code>twentythirteen_fonts_url()</code> function and there are no hooks so you ... | 2013/08/22 | [
"https://wordpress.stackexchange.com/questions/111190",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36983/"
] | The Twenty Thirteen theme uses Bitter for headings and Source Sans Pro for body text. I would like to change these.
The fonts are included by the line:
```
<link rel='stylesheet' id='twentythirteen-fonts-css' href='//fonts.googleapis.com/css?family=Source+Sans+Pro%3A300%2C400%2C700%2C300italic%2C400italic%2C700itali... | I looked at TwentyThirteen's `twentythirteen_fonts_url()` function and there are no hooks so you need to
[deregister](http://codex.wordpress.org/Function_Reference/wp_deregister_style) `twentythirteen-fonts` and enqueue your own fonts.
Removing the fonts is easy:
```
function deregister_gfonts_wpse_111190() {
wp_... |
111,194 | <p>Can we get uploaded image path in wordpress by filename?
Actually I know the way in PHP that will parse all files in the <strong>uploads</strong> folder, and matches the each file. But that way will produce high load on server, whenever I will run this script.</p>
<p>Is there any other possible way?</p>
<p>Thanks.... | [
{
"answer_id": 111201,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>I am not 100% sure I understand what you want but...</p>\n<p>WordPress treats attached media like a custom p... | 2013/08/22 | [
"https://wordpress.stackexchange.com/questions/111194",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15794/"
] | Can we get uploaded image path in wordpress by filename?
Actually I know the way in PHP that will parse all files in the **uploads** folder, and matches the each file. But that way will produce high load on server, whenever I will run this script.
Is there any other possible way?
Thanks.
Note: I do not have any post... | I am not 100% sure I understand what you want but...
WordPress treats attached media like a custom post type. The file name, minus the extension, is stored as the `post_title` in the `$wpdb->posts` table. So, to get the path just search for the file name minus the extension.
```
$q = new WP_Query(
array(
'field... |
111,200 | <p>What do you think it is the best approach to load a theme based on current window size of the client? I am not necessarily talking about resizing, but only about the size at the first load time. I made an attempt <a href="https://wordpress.stackexchange.com/questions/111039/change-theme-based-on-window-size-send-cli... | [
{
"answer_id": 111201,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>I am not 100% sure I understand what you want but...</p>\n<p>WordPress treats attached media like a custom p... | 2013/08/22 | [
"https://wordpress.stackexchange.com/questions/111200",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34740/"
] | What do you think it is the best approach to load a theme based on current window size of the client? I am not necessarily talking about resizing, but only about the size at the first load time. I made an attempt [here](https://wordpress.stackexchange.com/questions/111039/change-theme-based-on-window-size-send-client-w... | I am not 100% sure I understand what you want but...
WordPress treats attached media like a custom post type. The file name, minus the extension, is stored as the `post_title` in the `$wpdb->posts` table. So, to get the path just search for the file name minus the extension.
```
$q = new WP_Query(
array(
'field... |
111,202 | <p>I want to create a dummy menu with 1 or 2 level of depth. I know I can create the menu via the administration module, but I want to know if there is something I can use to generate fast a dummy menu.</p>
<p>I have a file with the sitemap indented by spaces that look as follow:</p>
<pre class="lang-none prettypri... | [
{
"answer_id": 111203,
"author": "GhostToast",
"author_id": 13676,
"author_profile": "https://wordpress.stackexchange.com/users/13676",
"pm_score": 2,
"selected": false,
"text": "<p>Why not make it just once, then use that database for all your development sites? </p>\n\n<p><a href=\"htt... | 2013/08/22 | [
"https://wordpress.stackexchange.com/questions/111202",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16001/"
] | I want to create a dummy menu with 1 or 2 level of depth. I know I can create the menu via the administration module, but I want to know if there is something I can use to generate fast a dummy menu.
I have a file with the sitemap indented by spaces that look as follow:
```none
Home
Foo
Foo 1
Foo 2
Foo 3
... | Why not make it just once, then use that database for all your development sites?
<http://codex.wordpress.org/Theme_Unit_Test> This has a link to a test database you can import (XML I believe), which has a few menus if I'm not mistaken. |
111,206 | <p>I'm trying to add a child theme to my wordpress installation. The theme the child should be based upon a theme called "nostalgia-landing" which is installed and works properly. I created a new folder called "nostalgia-custom" and added the the <em>style.css</em> with the following content:</p>
<pre><code>/*
Theme N... | [
{
"answer_id": 111224,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 2,
"selected": false,
"text": "<p>Two things come to mind:</p>\n\n<ol>\n<li><p>Is <code>nostalgia-landing</code> a child theme of something (Nost... | 2013/08/22 | [
"https://wordpress.stackexchange.com/questions/111206",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36984/"
] | I'm trying to add a child theme to my wordpress installation. The theme the child should be based upon a theme called "nostalgia-landing" which is installed and works properly. I created a new folder called "nostalgia-custom" and added the the *style.css* with the following content:
```
/*
Theme Name: Nostalgia Custom... | Problem solved: My child themes folder and the enclosed files had permission 750 instead of 644 set. Changed the permission and everything is working! |
111,223 | <p>I'm trying to fork this plugin to use the user email to login, as opposed to Username. </p>
<p>The plugin is <a href="http://wordpress.org/plugins/wp-modal-login/" rel="nofollow">http://wordpress.org/plugins/wp-modal-login/</a></p>
<p>Is there a nice way to do this, perhaps by a filter to get this plugin to work w... | [
{
"answer_id": 111817,
"author": "Eek",
"author_id": 37195,
"author_profile": "https://wordpress.stackexchange.com/users/37195",
"pm_score": 4,
"selected": true,
"text": "<p>I'm using this simple action, and it works like a charm. :)</p>\n\n<pre><code><?php\n/** Plugin Name: (#111223)... | 2013/08/22 | [
"https://wordpress.stackexchange.com/questions/111223",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19231/"
] | I'm trying to fork this plugin to use the user email to login, as opposed to Username.
The plugin is <http://wordpress.org/plugins/wp-modal-login/>
Is there a nice way to do this, perhaps by a filter to get this plugin to work with email credentials?
I've tried using this filter:
```
function custom_login() {
$d... | I'm using this simple action, and it works like a charm. :)
```
<?php
/** Plugin Name: (#111223) User Login with Mail Address */
add_action( 'wp_authenticate', 'wpse111223_login_with_email_address' );
function wpse111223_login_with_email_address( $username ) {
$user = get_user_by_email( $username );
if ( !... |
111,228 | <p>So I am developing a wordpress theme using a series of LESS files for the CSS. These compile using codekit to a combined and minifed stylesheet that I use for the theme's styling.</p>
<p>I understand a wordpress theme must have a style.css which includes the info about the theme in its comments, but is it required ... | [
{
"answer_id": 111497,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>Yes, WordPress uses the theme's <code>style.css</code> as a \"config\" document.</p>\n\n<p>You are also corr... | 2013/08/22 | [
"https://wordpress.stackexchange.com/questions/111228",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23620/"
] | So I am developing a wordpress theme using a series of LESS files for the CSS. These compile using codekit to a combined and minifed stylesheet that I use for the theme's styling.
I understand a wordpress theme must have a style.css which includes the info about the theme in its comments, but is it required to link th... | I would say: you *should not* use the `style.css` for the actual production CSS.
The reason is simple: minification. You cannot minify the content of the file completely, because WordPress has to read it. In my themes, I use `style.css` just for the headers, and I add a comment, explaining where to find the real CSS, ... |
111,229 | <p>this is how I'm getting the meta values:</p>
<pre><code>$apart_locations = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = 'postal_location' ORDER BY meta_value ASC" );
</code></pre>
<p>This is how I'm getting the published posts of a custom post type:</p>
<pre><code>$apartments = $... | [
{
"answer_id": 111313,
"author": "sri",
"author_id": 34200,
"author_profile": "https://wordpress.stackexchange.com/users/34200",
"pm_score": 0,
"selected": false,
"text": "<p>I think you are not doing the right thing here. Why don't you use WP_QUERY? It will get you posts in what ever wa... | 2013/08/22 | [
"https://wordpress.stackexchange.com/questions/111229",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3435/"
] | this is how I'm getting the meta values:
```
$apart_locations = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = 'postal_location' ORDER BY meta_value ASC" );
```
This is how I'm getting the published posts of a custom post type:
```
$apartments = $wpdb->get_col( "
SELECT DIS... | I am not sure if I get your question right, and thus don't know if this answer goes into the right direction... Is this what you're trying to achive?
```
$apart_locations = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta AS wppm
LEFT JOIN $wpdb->posts AS wpp ON wppm.post_id = wpp.ID
WHERE wppm.meta_ke... |
111,233 | <p>I need to get an array of all terms within a custom taxonomy where they have a parent term from another custom taxonomy. The example would be I have a custom taxonomy "School" where each term (in this example we can say the term is "NE High", but other terms would be "SE High" and "SW High") can have children terms ... | [
{
"answer_id": 111279,
"author": "Jake Lisby",
"author_id": 25283,
"author_profile": "https://wordpress.stackexchange.com/users/25283",
"pm_score": 0,
"selected": false,
"text": "<p>Alright, I figured out to do this I needed to use the \"parent\" attribute of the get_term() call. The dif... | 2013/08/22 | [
"https://wordpress.stackexchange.com/questions/111233",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25283/"
] | I need to get an array of all terms within a custom taxonomy where they have a parent term from another custom taxonomy. The example would be I have a custom taxonomy "School" where each term (in this example we can say the term is "NE High", but other terms would be "SE High" and "SW High") can have children terms fro... | In wordpress a parent for a term is always referred to the same taxonomy. So as you already understand what you need is create a texonomy in which parent term rapresents a 'School' and a child term rapresents a 'Group.' Maybe a third-level-term rapresents a 'Sub-Group' or something else.
Doing so and using the argumen... |
111,299 | <p>I noticed a lot of developers of WordPress themes would use this in <strong>functions.php</strong></p>
<pre><code>if (function_exists('register_nav_menus')) {
register_nav_menus (array('primary' => 'Header Navigation'));
}
</code></pre>
<p>For me, I alwayse use add_action for every function I am using in <s... | [
{
"answer_id": 111303,
"author": "Pontus Abrahamsson",
"author_id": 16722,
"author_profile": "https://wordpress.stackexchange.com/users/16722",
"pm_score": 3,
"selected": false,
"text": "<p>The <code>function_exists</code> function is not an other way to load the function like <code>add_... | 2013/08/23 | [
"https://wordpress.stackexchange.com/questions/111299",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34253/"
] | I noticed a lot of developers of WordPress themes would use this in **functions.php**
```
if (function_exists('register_nav_menus')) {
register_nav_menus (array('primary' => 'Header Navigation'));
}
```
For me, I alwayse use add\_action for every function I am using in **functions.php**
So, the above would be w... | Checking to see if built in WordPress functions exist before calling them is for backward compatibility which IMHO is not needed.
So if you see `if ( function_exists( 'register_nav_menus' ) )` the theme author is supporting versions earlier than 3.0.
You still sometimes see `if ( function_exists( 'dynamic_sidebar' ) ... |
111,325 | <p>I'm developing a theme for a friend, and I'm not sure what to put for the author, author uri, etc. Here is the Twenty Ten code:</p>
<pre><code>/*
Theme Name: Twenty Ten
Theme URI: http://wordpress.org/
Description: The 2010 default theme for WordPress.
Author: wordpressdotorg
Author URI: http://wordpress.org/
Versi... | [
{
"answer_id": 111328,
"author": "Prince Singh",
"author_id": 36972,
"author_profile": "https://wordpress.stackexchange.com/users/36972",
"pm_score": -1,
"selected": false,
"text": "<p>only thing required is </p>\n\n<pre><code>/*\nTheme Name: Twenty Ten\n*/\n</code></pre>\n\n<p>rest thin... | 2013/08/23 | [
"https://wordpress.stackexchange.com/questions/111325",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33541/"
] | I'm developing a theme for a friend, and I'm not sure what to put for the author, author uri, etc. Here is the Twenty Ten code:
```
/*
Theme Name: Twenty Ten
Theme URI: http://wordpress.org/
Description: The 2010 default theme for WordPress.
Author: wordpressdotorg
Author URI: http://wordpress.org/
Version: 1.0
Tags: ... | Prince's answer is technically true, but doesn't answer your specific questions. In the interest of getting you to learn more about WordPress, I'll get those:
>
> For Author, is that the blog owner, or the theme creator?
>
>
>
This should represent the theme author/creator.
>
> Author URI, is that the blog owne... |
111,334 | <p>I desperately need your help guys. I am trying to register custom post type and taxonomy the following way:</p>
<pre><code>add_action( 'init', 'product_catalog' );
add_action( 'init', 'product_type', 0 );
function product_catalog() {
$labels = array(
'name' => _x( 'Catalog', 'post type... | [
{
"answer_id": 111372,
"author": "Dan ",
"author_id": 5827,
"author_profile": "https://wordpress.stackexchange.com/users/5827",
"pm_score": 0,
"selected": false,
"text": "<p>I can't quite wrap my head around this without being able to use the code myself, but I have had issues like this.... | 2013/08/23 | [
"https://wordpress.stackexchange.com/questions/111334",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7954/"
] | I desperately need your help guys. I am trying to register custom post type and taxonomy the following way:
```
add_action( 'init', 'product_catalog' );
add_action( 'init', 'product_type', 0 );
function product_catalog() {
$labels = array(
'name' => _x( 'Catalog', 'post type general name' ),... | It's not working because "type" is reserved for [post format](http://codex.wordpress.org/Post_Formats) archive pages, i.e. `http://example.com/type/video`. |
111,336 | <p>I am new to Wordpress and am busy using it to create an online portfolio site. I have created a custom post type for my portfolio items called 'Portfolio', and I have attached a featured image to each custom post.</p>
<p>For my home page I would like a gallery of the featured images from these custom post types, an... | [
{
"answer_id": 111339,
"author": "Prince Singh",
"author_id": 36972,
"author_profile": "https://wordpress.stackexchange.com/users/36972",
"pm_score": 0,
"selected": false,
"text": "<pre><code><?php \nif (have_posts()) : \n while (have_posts()) : the_post(); \n if ( has_pos... | 2013/08/23 | [
"https://wordpress.stackexchange.com/questions/111336",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37031/"
] | I am new to Wordpress and am busy using it to create an online portfolio site. I have created a custom post type for my portfolio items called 'Portfolio', and I have attached a featured image to each custom post.
For my home page I would like a gallery of the featured images from these custom post types, and if you c... | To create the gallery you want, follow these steps:
1) Navigate to your theme folder and create a file named **cpt-gallery.php**
2) Copy and paste this code into the file
```
<?php
/*
Template Name: Custom Post Type Gallery
Description: Creates a gallery of featured images from a custom post type
... |
111,350 | <p>Today I've got a letter from my hosting provider that admin-ajax.php script had been sending spam until it was blocked. About two thousand spam messages were sent to different emails.
I know if you have proper mail function in your functions.php you can simply run the next code from Google Chrome console:</p>
<pre>... | [
{
"answer_id": 111352,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p><code>admin-ajax.php</code> by itself should not be a problem, but a poorly written function hooked to into ... | 2013/08/23 | [
"https://wordpress.stackexchange.com/questions/111350",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25831/"
] | Today I've got a letter from my hosting provider that admin-ajax.php script had been sending spam until it was blocked. About two thousand spam messages were sent to different emails.
I know if you have proper mail function in your functions.php you can simply run the next code from Google Chrome console:
```
$.ajax({... | This is why you use nonces.
===========================
```
$.ajax({
type: "POST",
url: '/wp-admin/admin-ajax.php',
data: { action: 'mail_function', message: 'test', _nonce: <?php echo wp_create_nonce( 'mail_function_' . $post->ID ) ?>},
dataType: "html",
success: function(data) {
}
});
```
T... |
111,351 | <p>I'm using Advanced Custom Fields making it easier for my client to manage his content.</p>
<p>On all of my child- and parent pages i would like to have the same header image and sidebar information. </p>
<p>Allthough i wish to make "Parent Page #1" and "Parent Page #2" have different information and this is contro... | [
{
"answer_id": 111358,
"author": "Angelique",
"author_id": 32037,
"author_profile": "https://wordpress.stackexchange.com/users/32037",
"pm_score": 1,
"selected": false,
"text": "<p>What about:</p>\n\n<pre><code><img src=\"<?php $parent_header_image = get_post_meta($post->post_pa... | 2013/08/23 | [
"https://wordpress.stackexchange.com/questions/111351",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26614/"
] | I'm using Advanced Custom Fields making it easier for my client to manage his content.
On all of my child- and parent pages i would like to have the same header image and sidebar information.
Allthough i wish to make "Parent Page #1" and "Parent Page #2" have different information and this is controlled with Advance... | In your loop, you can access the id of the parent page with `$post->post_parent`.
You just need to pass this value as second parameter:
```
<img src="<?php the_field('header_image', $post->post_parent ); ?>">
``` |
111,355 | <p>I noticed my twenty twelve theme is including outdated versions of jquery and js so I want to replace the scripts with the newer versions, however the scripts are in the file included by wp_head() (which I think is in wp-includes) so adding the scripts to my header means jquery will be loaded twice, I see now way to... | [
{
"answer_id": 111356,
"author": "Mark Davidson",
"author_id": 34111,
"author_profile": "https://wordpress.stackexchange.com/users/34111",
"pm_score": 1,
"selected": false,
"text": "<p>Simplest way to update jQuery is to use <a href=\"http://wordpress.org/plugins/jquery-updater/\" rel=\"... | 2013/08/23 | [
"https://wordpress.stackexchange.com/questions/111355",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2488/"
] | I noticed my twenty twelve theme is including outdated versions of jquery and js so I want to replace the scripts with the newer versions, however the scripts are in the file included by wp\_head() (which I think is in wp-includes) so adding the scripts to my header means jquery will be loaded twice, I see now way to r... | ```
add_action('wp_enqueue_scripts', 'no_more_jquery');
function no_more_jquery(){
wp_deregister_script('jquery');
}
```
That will deregister jquery. But why wouldn't you want jQuery at all?
If you mean to simply use your own, you should do it in that function, like this:
```
add_action('wp_enqueue_scripts', 'n... |
111,367 | <p>I'm trying to remove a filter from within my plugin class. I need to remove the 'continue reading' link from the_excerpt. The base theme is the twenty ten theme and they are applying a filter <code>twentyten_auto_excerpt_more</code>. I cannot remove the filter, I assume because I'm within a class:</p>
<pre><code>cl... | [
{
"answer_id": 111356,
"author": "Mark Davidson",
"author_id": 34111,
"author_profile": "https://wordpress.stackexchange.com/users/34111",
"pm_score": 1,
"selected": false,
"text": "<p>Simplest way to update jQuery is to use <a href=\"http://wordpress.org/plugins/jquery-updater/\" rel=\"... | 2013/08/23 | [
"https://wordpress.stackexchange.com/questions/111367",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27115/"
] | I'm trying to remove a filter from within my plugin class. I need to remove the 'continue reading' link from the\_excerpt. The base theme is the twenty ten theme and they are applying a filter `twentyten_auto_excerpt_more`. I cannot remove the filter, I assume because I'm within a class:
```
class MyAwesomeClass {
pr... | ```
add_action('wp_enqueue_scripts', 'no_more_jquery');
function no_more_jquery(){
wp_deregister_script('jquery');
}
```
That will deregister jquery. But why wouldn't you want jQuery at all?
If you mean to simply use your own, you should do it in that function, like this:
```
add_action('wp_enqueue_scripts', 'n... |
111,373 | <p>I am trying to include a dynamic css in my plugin, I have been searching anywhere but doesn't find any case that is similar to what I do. And what I use to do it is by adding a css file directly into the end of my plugin php file after the closing php tag <code>?></code> without adding any other stuffs like calli... | [
{
"answer_id": 111378,
"author": "Dan ",
"author_id": 5827,
"author_profile": "https://wordpress.stackexchange.com/users/5827",
"pm_score": 1,
"selected": false,
"text": "<p>I believe it's possible to dynamically write a CSS file using PHP, but you'd have to find out more on it, I don't ... | 2013/08/23 | [
"https://wordpress.stackexchange.com/questions/111373",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32989/"
] | I am trying to include a dynamic css in my plugin, I have been searching anywhere but doesn't find any case that is similar to what I do. And what I use to do it is by adding a css file directly into the end of my plugin php file after the closing php tag `?>` without adding any other stuffs like calling wp head etc.
... | You can use [wp\_add\_inline\_style()](http://codex.wordpress.org/Function_Reference/wp_add_inline_style) to add to a stylesheet that you've already defined, such as in your plugin. This way an options screen or other user settings can affect the final style output.
That could become very tedious, however, depending o... |
111,376 | <p>I'd like to say something on my page based on what page the person got there from. I can set up the link to that page to be:</p>
<pre><code>www.example.com/page?parameter=myparameter
</code></pre>
<p>Is there a way I can access that parameter so that I can have it show on the page, somewhere in my content?</p>
| [
{
"answer_id": 111379,
"author": "Dan ",
"author_id": 5827,
"author_profile": "https://wordpress.stackexchange.com/users/5827",
"pm_score": 2,
"selected": false,
"text": "<p>You could use a PHP session, look in the query object for the request, or use $_GET with your url, but it's not fo... | 2013/08/23 | [
"https://wordpress.stackexchange.com/questions/111376",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36515/"
] | I'd like to say something on my page based on what page the person got there from. I can set up the link to that page to be:
```
www.example.com/page?parameter=myparameter
```
Is there a way I can access that parameter so that I can have it show on the page, somewhere in my content? | Per the OP's answer within their question:
>
> With your help and some Googling, I put together a shortcode that returns the value of any url parameter. Here it is:
>
>
>
```
//THIS IS A CUSTOM SHORTCODE TO DISPLAY A PARAMETER FROM THE URL
function URLParam( $atts ) {
extract( shortcode_atts( array(
... |
111,377 | <p>this is a very general question, which I have really researched. Maybe I'm just being stupid, but I can't quite get when I can use a filter. After some messing around earlier, it seems I can take any function in the core files, pass this as the filter name, and the second argument I can replace this with my own func... | [
{
"answer_id": 111394,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 1,
"selected": false,
"text": "<p>The rule of thumb that I follow is:</p>\n\n<ul>\n<li>Use <a href=\"https://codex.wordpress.org/Function_Referen... | 2013/08/23 | [
"https://wordpress.stackexchange.com/questions/111377",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5827/"
] | this is a very general question, which I have really researched. Maybe I'm just being stupid, but I can't quite get when I can use a filter. After some messing around earlier, it seems I can take any function in the core files, pass this as the filter name, and the second argument I can replace this with my own functio... | [Filters](http://codex.wordpress.org/Plugin_API/Filter_Reference) and [Actions](http://codex.wordpress.org/Plugin_API/Action_Reference) are similar under the hood, but with an important difference-
**Actions** allow you to do something when an event occurs- WordPress does something and executes an action to let you do... |
111,401 | <p>I'm currently using a custom field called "Developing" to show whether or not a news story is a developing story. The custom field has a couple of values: a blank option (meaning it is not developing), "Yes," and "Was Developing." This is the code I use to display the word "Developing" in front of a news story title... | [
{
"answer_id": 111409,
"author": "Anjum",
"author_id": 3311,
"author_profile": "https://wordpress.stackexchange.com/users/3311",
"pm_score": 2,
"selected": true,
"text": "<p>use <code>get_post_meta($post->ID, 'your key', true);</code> instead of <code>get_meta();</code>\ncompare value... | 2013/08/23 | [
"https://wordpress.stackexchange.com/questions/111401",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34465/"
] | I'm currently using a custom field called "Developing" to show whether or not a news story is a developing story. The custom field has a couple of values: a blank option (meaning it is not developing), "Yes," and "Was Developing." This is the code I use to display the word "Developing" in front of a news story title:
... | use `get_post_meta($post->ID, 'your key', true);` instead of `get_meta();`
compare values like
```
$developing = get_post_meta($post->ID, 'developing', true);
if ($developing == 'value') {
// value is matched
} elseif ($developing == 'value2') {
// value 2 is matched
} else {
// not matched
}
``` |
111,421 | <p>I want to add some html under the title of a custom post type I created. See area in image here:</p>
<p><a href="https://i.stack.imgur.com/rpkV3.png" rel="nofollow noreferrer">http://i.stack.imgur.com/rpkV3.png</a></p>
<p>I tried using different methods including post_row_actions (depricated) filter to do this. ... | [
{
"answer_id": 111484,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>You can do this with a filter, but you have to do something you generally should not do-- <code>echo</code> ... | 2013/08/23 | [
"https://wordpress.stackexchange.com/questions/111421",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37054/"
] | I want to add some html under the title of a custom post type I created. See area in image here:
[http://i.stack.imgur.com/rpkV3.png](https://i.stack.imgur.com/rpkV3.png)
I tried using different methods including post\_row\_actions (depricated) filter to do this. Does anyone know of a function or a method on how to d... | You could do this by adding a notice, they appear in that spot.
Something like this would add a notice just for pages. You would obviously need to adjust the if statement for your CPT and to show on what pages you want.
```
function my_admin_notice() {
global $pagenow;
if (( $pagenow == 'edit.php' ) && ($_G... |
111,435 | <p>is it possible to wrap the featured image on the add/edit page in a div or other code? I don't mean on the front page of the website, but on the back end on the add/edit pages when you're typing up your post. I'm trying to add this code around it:</p>
<pre><code><div id="draggable" class="ui-widget-content">
... | [
{
"answer_id": 111438,
"author": "micjamking",
"author_id": 36130,
"author_profile": "https://wordpress.stackexchange.com/users/36130",
"pm_score": -1,
"selected": false,
"text": "<p>The short answer is no. </p>\n\n<p>The Edit Post screen in WordPress admin only provides the ability for ... | 2013/08/23 | [
"https://wordpress.stackexchange.com/questions/111435",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34465/"
] | is it possible to wrap the featured image on the add/edit page in a div or other code? I don't mean on the front page of the website, but on the back end on the add/edit pages when you're typing up your post. I'm trying to add this code around it:
```
<div id="draggable" class="ui-widget-content">
<p>Featured Image Co... | When you post [this question](https://wordpress.stackexchange.com/questions/111428/change-width-of-featured-image-thumbnail-on-add-edit-post-page) @PontusAbrahamsson answered you with a good function:
```
function wpse_111428_change_feature_image_admin( $content )
{
global $post;
$size = 100;
$id = get_... |
111,436 | <p>I have a custom table in the WP database which I can display fine, with pagination, using the following code:</p>
<pre><code><?php
global $wpdb;
$rows_per_page = 50;
$current = (intval(get_query_var('paged'))) ? intval(get_query_var('paged')) : 1;
$rows = $wpdb->get_results( "SELECT * FROM nc_rates_eng");
... | [
{
"answer_id": 111442,
"author": "Digitalchild",
"author_id": 3170,
"author_profile": "https://wordpress.stackexchange.com/users/3170",
"pm_score": 2,
"selected": false,
"text": "<p>I would use a <a href=\"http://codex.wordpress.org/Custom_Queries#Keyword_Search_in_Plugin_Table\" rel=\"n... | 2013/08/23 | [
"https://wordpress.stackexchange.com/questions/111436",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37060/"
] | I have a custom table in the WP database which I can display fine, with pagination, using the following code:
```
<?php
global $wpdb;
$rows_per_page = 50;
$current = (intval(get_query_var('paged'))) ? intval(get_query_var('paged')) : 1;
$rows = $wpdb->get_results( "SELECT * FROM nc_rates_eng");
global $wp_rewrite;
... | I would use a [custom query](http://codex.wordpress.org/Custom_Queries#Keyword_Search_in_Plugin_Table)
This explains how to search for keywords in a custom table. You could adjust this as required to your table and required output. |
111,441 | <p>I want to enable comments for custom post types just like they are for standard posts, but can't seem to get it to work.</p>
<p>In functions.php, as part of registering my custom post type, I have this:</p>
<pre><code>'supports' => array('title', 'author', 'thumbnail', 'comments', 'revisions'),
</code></pre>
<... | [
{
"answer_id": 111442,
"author": "Digitalchild",
"author_id": 3170,
"author_profile": "https://wordpress.stackexchange.com/users/3170",
"pm_score": 2,
"selected": false,
"text": "<p>I would use a <a href=\"http://codex.wordpress.org/Custom_Queries#Keyword_Search_in_Plugin_Table\" rel=\"n... | 2013/08/24 | [
"https://wordpress.stackexchange.com/questions/111441",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36242/"
] | I want to enable comments for custom post types just like they are for standard posts, but can't seem to get it to work.
In functions.php, as part of registering my custom post type, I have this:
```
'supports' => array('title', 'author', 'thumbnail', 'comments', 'revisions'),
```
In my single post type template I ... | I would use a [custom query](http://codex.wordpress.org/Custom_Queries#Keyword_Search_in_Plugin_Table)
This explains how to search for keywords in a custom table. You could adjust this as required to your table and required output. |
111,447 | <p>I'm trying to display a custom widget in the sidebar of my homepage (which is a static front page defined in <code>Settings > Reading</code>). Here is the relevant part of my <code>sidebar.php</code>:</p>
<pre><code>if ( is_front_page() || is_home() ) {
if ( is_active_sidebar( 'sidebar_lecture' ) ) : ?>
... | [
{
"answer_id": 111442,
"author": "Digitalchild",
"author_id": 3170,
"author_profile": "https://wordpress.stackexchange.com/users/3170",
"pm_score": 2,
"selected": false,
"text": "<p>I would use a <a href=\"http://codex.wordpress.org/Custom_Queries#Keyword_Search_in_Plugin_Table\" rel=\"n... | 2013/08/24 | [
"https://wordpress.stackexchange.com/questions/111447",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33075/"
] | I'm trying to display a custom widget in the sidebar of my homepage (which is a static front page defined in `Settings > Reading`). Here is the relevant part of my `sidebar.php`:
```
if ( is_front_page() || is_home() ) {
if ( is_active_sidebar( 'sidebar_lecture' ) ) : ?>
<div id="secondary" class="widget-a... | I would use a [custom query](http://codex.wordpress.org/Custom_Queries#Keyword_Search_in_Plugin_Table)
This explains how to search for keywords in a custom table. You could adjust this as required to your table and required output. |
111,450 | <p>I am working on a custom theme. In that theme, I am creating a menu called "social" for links to the social sites, such as twitter, facebook, ...etc.</p>
<p>Now, Instead of text, I would like to display social media icons. How can I do that? Make every menu item an image?</p>
<p>Thanks.</p>
| [
{
"answer_id": 111453,
"author": "C Sanchez",
"author_id": 37064,
"author_profile": "https://wordpress.stackexchange.com/users/37064",
"pm_score": 1,
"selected": false,
"text": "<p>This would be my solution to the problem if you want to make edits on the back-end(Admin area) in the site ... | 2013/08/24 | [
"https://wordpress.stackexchange.com/questions/111450",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34253/"
] | I am working on a custom theme. In that theme, I am creating a menu called "social" for links to the social sites, such as twitter, facebook, ...etc.
Now, Instead of text, I would like to display social media icons. How can I do that? Make every menu item an image?
Thanks. | This would be my solution to the problem if you want to make edits on the back-end(Admin area) in the site at any time. If you want a static menu just insert step 1 where you needed it and skip the rest. Hope it helps!
Your CODE will look similar to this:
Step 1) Create menu and insert images in images folder within ... |
111,465 | <p>I have a custom post type called Events, with 2 custom fields, start date and end date. These fields are stored using a timestamp in the database. I want to create a custom query based on these 2 values, so i can list events that are inside the specified date/time range. This is how my code looks like:</p>
<pre><co... | [
{
"answer_id": 111530,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 1,
"selected": true,
"text": "<p>I think you have used wrong comparison operators in meta query .It should be >= for 'event_start_date' and... | 2013/08/24 | [
"https://wordpress.stackexchange.com/questions/111465",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8038/"
] | I have a custom post type called Events, with 2 custom fields, start date and end date. These fields are stored using a timestamp in the database. I want to create a custom query based on these 2 values, so i can list events that are inside the specified date/time range. This is how my code looks like:
```
$start_date... | I think you have used wrong comparison operators in meta query .It should be >= for 'event\_start\_date' and <= for 'event\_end\_date' . |
111,474 | <p>I'm trying to follow <a href="http://jasonbradley.me/icons-in-the-wordpress-menu/" rel="nofollow">Jason Bradley's advice</a> on how to style my Wordpress menus.</p>
<p>Specifically, I want to insert an icon before my navigation items using <a href="http://fontawesome.io/examples/#navigation" rel="nofollow">Font-Awe... | [
{
"answer_id": 111477,
"author": "Manu",
"author_id": 22963,
"author_profile": "https://wordpress.stackexchange.com/users/22963",
"pm_score": 3,
"selected": true,
"text": "<p>The \"Navigation\" field is <em>not</em> where you want to place your CSS class. The navigation is what the user ... | 2013/08/24 | [
"https://wordpress.stackexchange.com/questions/111474",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33075/"
] | I'm trying to follow [Jason Bradley's advice](http://jasonbradley.me/icons-in-the-wordpress-menu/) on how to style my Wordpress menus.
Specifically, I want to insert an icon before my navigation items using [Font-Awesome](http://fontawesome.io/examples/#navigation).
I tried putting this code in the Navigation Label f... | The "Navigation" field is *not* where you want to place your CSS class. The navigation is what the user will see in the menu, so don't put any code there.
To enter a custom CSS class to your item, you need to do the following:
* Click the "Screen Options" tab in the top right corner of the page.
* Under "Show advanc... |
111,517 | <p>i want to make a custom template using Genesis..
I added a custom Menu just by adding a widget on WIDGETS section and placed it on the top right side of the page. But i want it to be removed in a specific template ... How can i do that?? </p>
<pre><code><?php
/*
Template Name: No Menu - Full Page
*/
?>
<... | [
{
"answer_id": 111518,
"author": "Eugenious",
"author_id": 37096,
"author_profile": "https://wordpress.stackexchange.com/users/37096",
"pm_score": 1,
"selected": false,
"text": "<p>The menu is most likely part of the file header.php, which is called from get_header(). To alter the header... | 2013/08/25 | [
"https://wordpress.stackexchange.com/questions/111517",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36088/"
] | i want to make a custom template using Genesis..
I added a custom Menu just by adding a widget on WIDGETS section and placed it on the top right side of the page. But i want it to be removed in a specific template ... How can i do that??
```
<?php
/*
Template Name: No Menu - Full Page
*/
?>
<?php get_header(); ?>
<... | The menu is most likely part of the file header.php, which is called from get\_header(). To alter the header just for your custom template, you may create another header file (e.g. header-no-menu.php), and call it using get\_header('no-menu'). Here's a link to some documentation: <http://codex.wordpress.org/Function_Re... |
111,537 | <p>i tried to use iris color picker in my plugin admin area but when i implemented i'm getting this error- </p>
<blockquote>
<p>TypeError: $(...).wpColorPicker is not a functionCode-</p>
</blockquote>
<pre><code>function sam()
{
wp_enqueue_style( 'wp-color-picker');
wp_enqueue_script( 'wp-color-picker');
}
add_acti... | [
{
"answer_id": 111574,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 2,
"selected": false,
"text": "<p>This is happening because you are calling wpColorPicker function before loading wp-color-picker script so... | 2013/08/25 | [
"https://wordpress.stackexchange.com/questions/111537",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37102/"
] | i tried to use iris color picker in my plugin admin area but when i implemented i'm getting this error-
>
> TypeError: $(...).wpColorPicker is not a functionCode-
>
>
>
```
function sam()
{
wp_enqueue_style( 'wp-color-picker');
wp_enqueue_script( 'wp-color-picker');
}
add_action( 'admin_enqueue_scripts', 'sam' )... | This is happening because you are calling wpColorPicker function before loading wp-color-picker script so to overcome this situation call wpColorPicker() function after loading wp-color-picker script by adding following script in js file in this example i have added it in wp-color-picker-script.js.
```
jQuery(document... |
111,548 | <p>I'm working on a site where I'd like anyone to be able to sign up, but people who sign up with an invitation code would automatically be registered to an existing group associated with that code. How can I do this?</p>
<p>I have not yet chosen how groups will be created, but I know that this can be done with one of... | [
{
"answer_id": 111711,
"author": "GhostToast",
"author_id": 13676,
"author_profile": "https://wordpress.stackexchange.com/users/13676",
"pm_score": 2,
"selected": false,
"text": "<p>Not sure how you want to handle groups, but it could just be user_meta. </p>\n\n<p>Regardless, you could u... | 2013/08/25 | [
"https://wordpress.stackexchange.com/questions/111548",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25187/"
] | I'm working on a site where I'd like anyone to be able to sign up, but people who sign up with an invitation code would automatically be registered to an existing group associated with that code. How can I do this?
I have not yet chosen how groups will be created, but I know that this can be done with one of these plu... | Not sure how you want to handle groups, but it could just be user\_meta.
Regardless, you could use Gravity Forms + user registration add-on to process a user registration and determine what group the user should be added to. This should work even if you are using third-party hooks.
If it's simple user\_meta, you ca... |
111,557 | <p>I am having trouble understanding this error and I've not come across it before, please could someone help? </p>
<pre><code>Strict Standards: Declaration of wp_bootstrap_navwalker::start_lvl() should be compatible with Walker_Nav_Menu::start_lvl(&$output, $depth = 0, $args = Array) in .../wp-content/themes/flat... | [
{
"answer_id": 111558,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 5,
"selected": true,
"text": "<p>It means that the declaration of the <code>start_lvl</code> method in <code>wp_bootstrap_navwalker</code> sho... | 2013/08/25 | [
"https://wordpress.stackexchange.com/questions/111557",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33243/"
] | I am having trouble understanding this error and I've not come across it before, please could someone help?
```
Strict Standards: Declaration of wp_bootstrap_navwalker::start_lvl() should be compatible with Walker_Nav_Menu::start_lvl(&$output, $depth = 0, $args = Array) in .../wp-content/themes/flat-portfolio/wp_boot... | It means that the declaration of the `start_lvl` method in `wp_bootstrap_navwalker` should match the declaration of the method in [`Walker_Nav_Menu`](http://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes/nav-menu.php#L10). It doesn't.
```
function start_lvl( &$output, $depth ) {
```
VS.
```
function st... |
111,563 | <p><strong>In my WordPress blog I included a javascript-based slideshow</strong> at the top which works well. I have a PHP file which outputs the necessary javascript that has to go in the <code><head></code> tag by means of an "add_action" in my child theme's functions.php file:</p>
<pre><code>function add_sli... | [
{
"answer_id": 111566,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>My guess is that you have a plugin that manipulating script registration so that jQuery loads in the footer.... | 2013/08/25 | [
"https://wordpress.stackexchange.com/questions/111563",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27103/"
] | **In my WordPress blog I included a javascript-based slideshow** at the top which works well. I have a PHP file which outputs the necessary javascript that has to go in the `<head>` tag by means of an "add\_action" in my child theme's functions.php file:
```
function add_slideshow_js() {
include('/path/slideshow_outpu... | By default if you enqueue jquery then it gets added in header but if any plugin is changing the default behavior of it and adding it in footer instead of header then you can use the following code to alter it and force it to add in header again.
```
function insert_jquery(){
wp_enqueue_script('jquery', false, array(),... |
111,564 | <p>I would like to create a three columns with 3 selected posts. They must include image and title. Like this <a href="https://i.imgur.com/tXg0bv3.png" rel="nofollow noreferrer">http://i.imgur.com/tXg0bv3.png</a>
How to create it in CSS and HTML?
This is very important for me, I can't find something like that. Thanks.<... | [
{
"answer_id": 111566,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>My guess is that you have a plugin that manipulating script registration so that jQuery loads in the footer.... | 2013/08/25 | [
"https://wordpress.stackexchange.com/questions/111564",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36902/"
] | I would like to create a three columns with 3 selected posts. They must include image and title. Like this [http://i.imgur.com/tXg0bv3.png](https://i.imgur.com/tXg0bv3.png)
How to create it in CSS and HTML?
This is very important for me, I can't find something like that. Thanks.
I'm sorry, I did not mention. This colu... | By default if you enqueue jquery then it gets added in header but if any plugin is changing the default behavior of it and adding it in footer instead of header then you can use the following code to alter it and force it to add in header again.
```
function insert_jquery(){
wp_enqueue_script('jquery', false, array(),... |
111,576 | <p>I've run a get_posts query in WordPress and need to pull a pair of custom fields and get all of them into one array. The get_posts query provides an array of posts, but when I use foreach to access the custom fields, I end up with separate arrays for each result. </p>
<p><strong>The Query</strong></p>
<pre><code>$... | [
{
"answer_id": 111566,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>My guess is that you have a plugin that manipulating script registration so that jQuery loads in the footer.... | 2013/08/25 | [
"https://wordpress.stackexchange.com/questions/111576",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24181/"
] | I've run a get\_posts query in WordPress and need to pull a pair of custom fields and get all of them into one array. The get\_posts query provides an array of posts, but when I use foreach to access the custom fields, I end up with separate arrays for each result.
**The Query**
```
$c_query = get_posts(
... | By default if you enqueue jquery then it gets added in header but if any plugin is changing the default behavior of it and adding it in footer instead of header then you can use the following code to alter it and force it to add in header again.
```
function insert_jquery(){
wp_enqueue_script('jquery', false, array(),... |
111,619 | <p>I am very new to WordPress and here I want to create one admin page with tabs as shown in image</p>
<p><img src="https://i.stack.imgur.com/EIcLq.png" alt="admin sections with tabs"></p>
<p>How can I create such page with these tabs?</p>
| [
{
"answer_id": 174945,
"author": "Vincent Wong",
"author_id": 66041,
"author_profile": "https://wordpress.stackexchange.com/users/66041",
"pm_score": 0,
"selected": false,
"text": "<p>You can use OptionTree plugin <a href=\"https://wordpress.org/plugins/option-tree/\" rel=\"nofollow nore... | 2013/08/26 | [
"https://wordpress.stackexchange.com/questions/111619",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37136/"
] | I am very new to WordPress and here I want to create one admin page with tabs as shown in image

How can I create such page with these tabs? | if you don't like this method. maybe you would like the follow code:

you can try to put the follow code in your functions.php file-
```
// Theme options
/*
get options & set default options
*/
if( !function_exists('share3h_th... |
111,628 | <p>Is it possible to include a external PHP file into a custom template? </p>
<p>I'm trying to add a blog into my site. I already have the header, footer, and sidebar layout in my site. Can I use those in my custom template? </p>
<pre><code><?php
/*
Template Name: Blog
*/
?>
<?php include( PATH . 'http://www... | [
{
"answer_id": 132234,
"author": "Giorgio Tedesco",
"author_id": 46082,
"author_profile": "https://wordpress.stackexchange.com/users/46082",
"pm_score": 1,
"selected": false,
"text": "<p>You cannot include an external resource on <code>include()</code> functions! Include works by server ... | 2013/08/26 | [
"https://wordpress.stackexchange.com/questions/111628",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36088/"
] | Is it possible to include a external PHP file into a custom template?
I'm trying to add a blog into my site. I already have the header, footer, and sidebar layout in my site. Can I use those in my custom template?
```
<?php
/*
Template Name: Blog
*/
?>
<?php include( PATH . 'http://www.example.com/includes/header.p... | No, you cannot include PHP files in a theme the way you indicated.
To see why, all we have to do is exercise some common sense and basic critical thinking:
1. You would be doing a remote request to a remote server `include` cannot do this
2. If by some miracle it worked, you would have a major security exploit as I c... |
111,634 | <p>I'm trying to make a multi column layout. Seen as CSS3 adoption of column layouts is still thin on the ground, I was thinking maybe I could grab the first half of all my posts (and then the second), and add them in their own UL elements.</p>
<p>I'm not sure how / if this is possible with a Wp_Query?</p>
<p>I want ... | [
{
"answer_id": 111636,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": true,
"text": "<p>If you want to split it into two lists, you could use <a href=\"http://codex.wordpress.org/Function_Reference/... | 2013/08/26 | [
"https://wordpress.stackexchange.com/questions/111634",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6353/"
] | I'm trying to make a multi column layout. Seen as CSS3 adoption of column layouts is still thin on the ground, I was thinking maybe I could grab the first half of all my posts (and then the second), and add them in their own UL elements.
I'm not sure how / if this is possible with a Wp\_Query?
I want to end up with m... | If you want to split it into two lists, you could use [`wp_count_posts()`](http://codex.wordpress.org/Function_Reference/wp_count_posts) to count the number of your published posts
```
$total_cpt = wp_count_posts('cpt')->publish;
```
divide it by 2:
```
$half_of_cpt = sprintf( '%d', $total_cpt / 2 );
```
and the... |
111,635 | <p>I want to display thumbnails of multiple categories on a page, i am having hard time accessing the categories as it shows empty. is something wrong with my code?</p>
<pre><code> $args = array(
'per_page' => '12',
'category_name' => 'travel',
... | [
{
"answer_id": 111640,
"author": "Rahil Wazir",
"author_id": 36349,
"author_profile": "https://wordpress.stackexchange.com/users/36349",
"pm_score": 4,
"selected": true,
"text": "<p>You're passing bad array keys to <code>$args</code>. Do something like this:</p>\n\n<pre><code>$args = arr... | 2013/08/26 | [
"https://wordpress.stackexchange.com/questions/111635",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33028/"
] | I want to display thumbnails of multiple categories on a page, i am having hard time accessing the categories as it shows empty. is something wrong with my code?
```
$args = array(
'per_page' => '12',
'category_name' => 'travel',
... | You're passing bad array keys to `$args`. Do something like this:
```
$args = array(
'posts_per_page' => '12',
'product_cat' => 'lead-generation',
'post_type' => 'product',
'orderby' => 'title',
);
$query = new WP_Query( $args );
if( $query->have_posts()) : while( $query->have_post... |
111,647 | <p>I registered a wordpress menu this way:</p>
<pre><code>function nothing_register_menus() {
register_nav_menu('header-menu',__( 'Header Menu' ));
}
add_action( 'init', 'nothing_register_menus' );
</code></pre>
<p>I am calling wp_nav_menu that way:</p>
<pre><code>wp_nav_menu( array(
'theme_locatio... | [
{
"answer_id": 111700,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 2,
"selected": false,
"text": "<p>Straight from <a href=\"http://codex.wordpress.org/Function_Reference/wp_nav_menu#Parameters\" rel=\"nofollo... | 2013/08/26 | [
"https://wordpress.stackexchange.com/questions/111647",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23612/"
] | I registered a wordpress menu this way:
```
function nothing_register_menus() {
register_nav_menu('header-menu',__( 'Header Menu' ));
}
add_action( 'init', 'nothing_register_menus' );
```
I am calling wp\_nav\_menu that way:
```
wp_nav_menu( array(
'theme_location' => 'header-menu',
... | your problem is in your use `'menu_class'` and `'items_wrap'` not synchronized.
You can edit :
```
wp_nav_menu( array(
'theme_location' => 'header-menu',
'container' => '',
'echo' => '0',
'menu_class' => 'nav-menu horiz-menu container sixteen columns',
... |
111,671 | <p>I have a custom post type named 'Projecten' with a taxonomy called 'fases_projecten', in there i have 'concept', 'inontwikkeling' and 'gerealiseerd'.
In my template I'm using the following code for displaying changes between the sevral fases/terms.</p>
<pre><code>`<?php if( has_term( 'concept', 'fases_projecte... | [
{
"answer_id": 111672,
"author": "Ciprian",
"author_id": 7349,
"author_profile": "https://wordpress.stackexchange.com/users/7349",
"pm_score": 1,
"selected": false,
"text": "<p>Just use <code>else</code> so your last lines would become:</p>\n\n<p><code><?php else { ?><div class=... | 2013/08/26 | [
"https://wordpress.stackexchange.com/questions/111671",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34616/"
] | I have a custom post type named 'Projecten' with a taxonomy called 'fases\_projecten', in there i have 'concept', 'inontwikkeling' and 'gerealiseerd'.
In my template I'm using the following code for displaying changes between the sevral fases/terms.
```
`<?php if( has_term( 'concept', 'fases_projecten' ) ) { ?><div c... | Use [`get_the_terms()`](http://codex.wordpress.org/Function_Reference/get_the_terms).
```
if (false === get_the_terms( $post_id, 'post_tag' )) {
// has no post tags at all
}
```
I am not sure there is an existing core function to test specifically for the absence of any term at all including custom taxonomies but ... |
111,673 | <p>I've searched numerous StackOverflow and Wordpress Awnsers questions, but I couldn't find any solution that matches my situation or even remotely points me in the right direction.</p>
<p>I have a custom media frame in my plugin where I have pre-selected certain images out of a media library of about 3000 images. Ho... | [
{
"answer_id": 112543,
"author": "Ogier Schelvis",
"author_id": 37152,
"author_profile": "https://wordpress.stackexchange.com/users/37152",
"pm_score": 3,
"selected": true,
"text": "<p>After reading up on the Backbone.js documentation I found out it's quite easy to manually add attachmen... | 2013/08/26 | [
"https://wordpress.stackexchange.com/questions/111673",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37152/"
] | I've searched numerous StackOverflow and Wordpress Awnsers questions, but I couldn't find any solution that matches my situation or even remotely points me in the right direction.
I have a custom media frame in my plugin where I have pre-selected certain images out of a media library of about 3000 images. However, the... | After reading up on the Backbone.js documentation I found out it's quite easy to manually add attachments by ID to the library of the media frame.
You can just assign a reference to the library on the open event. Then create an instance of wp.media.attachment. Fetch it. And then call the add function on your library r... |
111,690 | <p>I have a Plugin with 3 submenu_pages.
In one page is a formular (in one some text and in one a list of items). when I submit the form, there will be done some processing. after that I don't want to get back to the form-page, but WP shell redirect me to one of the other submenu_pages (in this case a list).</p>
<p>ho... | [
{
"answer_id": 111688,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://core.trac.wordpress.org/browser/tags/3.6/wp-includes/general-template.php#L24\" rel=\"nofol... | 2013/08/26 | [
"https://wordpress.stackexchange.com/questions/111690",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32871/"
] | I have a Plugin with 3 submenu\_pages.
In one page is a formular (in one some text and in one a list of items). when I submit the form, there will be done some processing. after that I don't want to get back to the form-page, but WP shell redirect me to one of the other submenu\_pages (in this case a list).
how can I ... | [`get_header()`](http://core.trac.wordpress.org/browser/tags/3.6/wp-includes/general-template.php#L24) is not filterable. Neither is [`locate_template()`](http://core.trac.wordpress.org/browser/tags/3.6/wp-includes/template.php#L368).
Themes can alter which header loads by passing a parameter to `get_header()`. There... |
111,718 | <p>This is a twentytwelve wordpress child theme, and it's located at www.travelwithcastle.com </p>
<p>I'd very much like to delete the enormous preview pic that shows up on top of the actual post page. It's the feature pic I chose to be the preview pic for the homepage. I love the picture, but that picture is already ... | [
{
"answer_id": 111723,
"author": "GhostToast",
"author_id": 13676,
"author_profile": "https://wordpress.stackexchange.com/users/13676",
"pm_score": 0,
"selected": false,
"text": "<p>Remove <code>the_post_thumbnail();</code> and this won't show up.</p>\n"
},
{
"answer_id": 111724,... | 2013/08/26 | [
"https://wordpress.stackexchange.com/questions/111718",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35310/"
] | This is a twentytwelve wordpress child theme, and it's located at www.travelwithcastle.com
I'd very much like to delete the enormous preview pic that shows up on top of the actual post page. It's the feature pic I chose to be the preview pic for the homepage. I love the picture, but that picture is already within the... | This will work:
```
<?php if ( is_home() ) : ?>
<?php the_post_thumbnail(); ?>
<?php endif; ?>
```
This code will only show your feature image on homepage and not in post page. |
111,729 | <p>I am trying to get buddypress avatars on a network's main site from a sub-site. The way buddypress does avatars is really involved with loops and fallbacks etc and doesn't consist of any database calls, which would have been straightforward.</p>
<p>Instead I thought maybe I will create a function on my main site to... | [
{
"answer_id": 111732,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 0,
"selected": false,
"text": "<p>Pass the blog ID of the sub-site to your AJAX callback handler, use <code>switch_to_blog()</code> there and get the d... | 2013/08/26 | [
"https://wordpress.stackexchange.com/questions/111729",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8325/"
] | I am trying to get buddypress avatars on a network's main site from a sub-site. The way buddypress does avatars is really involved with loops and fallbacks etc and doesn't consist of any database calls, which would have been straightforward.
Instead I thought maybe I will create a function on my main site to output th... | There's two parts to this, the javascript ajax call needs specific variables included:
```
$.ajax({
type: "GET",
url: SSL_Ajax.ajaxurl,
cache: false,
dataType: "jsonp",
crossDomain: true,
data: {
action : 'aja... |
111,767 | <p>I have a template that is used for many different sections of my site (About, News, etc.). The nav bar needs to show a little graphic arrow below the section you're in. I was passing this via the template:</p>
<pre><code>$page = 'about';
require('header.php');
</code></pre>
<p>...but then I realized that won't wor... | [
{
"answer_id": 111769,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 3,
"selected": true,
"text": "<p>Idea #1 is correct if your template use <code>body_class()</code> like</p>\n\n<pre><code><body <?php bod... | 2013/08/27 | [
"https://wordpress.stackexchange.com/questions/111767",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13981/"
] | I have a template that is used for many different sections of my site (About, News, etc.). The nav bar needs to show a little graphic arrow below the section you're in. I was passing this via the template:
```
$page = 'about';
require('header.php');
```
...but then I realized that won't work since the template file ... | Idea #1 is correct if your template use `body_class()` like
```
<body <?php body_class(); ?>>
```
In this case the body tag will be something like:
```
<body class="page page-id-6 page-template-default">
```
If the id of viewed page is 6 and template used is the default.
See [Codex](http://codex.wordpress.org/Fu... |
111,772 | <p>I'm looking to display a different price based on a user role (wholesaler, dealer, etc) AND based on the category.</p>
<p>There's a dynamic pricing plugin that displays these discounts once an item is added to the cart, but not on the page itself.</p>
<p>Is there a way to use a filter or action to check for the us... | [
{
"answer_id": 111788,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 4,
"selected": false,
"text": "<p>Yes there is, you can use the <code>woocommerce_get_price</code> filter hook to filter the value based on ... | 2013/08/27 | [
"https://wordpress.stackexchange.com/questions/111772",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37177/"
] | I'm looking to display a different price based on a user role (wholesaler, dealer, etc) AND based on the category.
There's a dynamic pricing plugin that displays these discounts once an item is added to the cart, but not on the page itself.
Is there a way to use a filter or action to check for the user level, check t... | Yes there is, you can use the `woocommerce_get_price` filter hook to filter the value based on user role and return a price accordingly e.g:
```
add_filter('woocommerce_get_price', 'custom_price_WPA111772', 10, 2);
/**
* custom_price_WPA111772
*
* filter the price based on category and user role
* @param $price ... |
111,775 | <p>I created a custom taxonomy called Location then added New Jersey, New York, etc. Is there a Wordpress function that will get the list of all ids under the Location similar to what get_all_category_ids() does?</p>
| [
{
"answer_id": 111788,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 4,
"selected": false,
"text": "<p>Yes there is, you can use the <code>woocommerce_get_price</code> filter hook to filter the value based on ... | 2013/08/27 | [
"https://wordpress.stackexchange.com/questions/111775",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36874/"
] | I created a custom taxonomy called Location then added New Jersey, New York, etc. Is there a Wordpress function that will get the list of all ids under the Location similar to what get\_all\_category\_ids() does? | Yes there is, you can use the `woocommerce_get_price` filter hook to filter the value based on user role and return a price accordingly e.g:
```
add_filter('woocommerce_get_price', 'custom_price_WPA111772', 10, 2);
/**
* custom_price_WPA111772
*
* filter the price based on category and user role
* @param $price ... |
111,785 | <p>As you know the result of the <code>the_post_thumbnail()</code> is an image tag. I need this image tag to store at a kind of collection or Array. I'm using the following code but it doesn't help me out. And I want to use it at another place and print out as an image tag.</p>
<pre><code><?php $tmp_query = new WP_... | [
{
"answer_id": 111806,
"author": "Charles Clarkson",
"author_id": 31788,
"author_profile": "https://wordpress.stackexchange.com/users/31788",
"pm_score": 1,
"selected": false,
"text": "<p>Most WordPress functions that echo a result have sister function that return the result. To find the... | 2013/08/27 | [
"https://wordpress.stackexchange.com/questions/111785",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35212/"
] | As you know the result of the `the_post_thumbnail()` is an image tag. I need this image tag to store at a kind of collection or Array. I'm using the following code but it doesn't help me out. And I want to use it at another place and print out as an image tag.
```
<?php $tmp_query = new WP_Query('showposts=6');
$count... | With a tiny bit of research, I'm pretty sure you could have created this yourself:
```
$featimage = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' )[0];
$printable_url = '<img src="' . $featimage . '">';
echo $printable_url;
```
Edit: Since PHP 5 is defunct, you can reference the first node i... |
111,816 | <p>I'm using the CMB framework for creating metaboxes (<a href="https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress" rel="nofollow">https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress</a>)</p>
<p>and I want to add a select box which prepopulates with titles from a custom post type... | [
{
"answer_id": 111821,
"author": "Charles Clarkson",
"author_id": 31788,
"author_profile": "https://wordpress.stackexchange.com/users/31788",
"pm_score": 1,
"selected": false,
"text": "<p>Use a function that returns an array of arrays that the <code>options</code> field expects.</p>\n\n<... | 2013/08/27 | [
"https://wordpress.stackexchange.com/questions/111816",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37054/"
] | I'm using the CMB framework for creating metaboxes (<https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress>)
and I want to add a select box which prepopulates with titles from a custom post type. A normal select box looks like:
```
array(
'name' => 'Test Select',
'desc' => 'field description ... | Use a function that returns an array of arrays that the `options` field expects.
Something like this (untested code):
```
array(
'name' => 'Test Select',
'desc' => 'field description (optional)',
'id' => $prefix . 'test_select',
'type' => 'select',
'options' => get_myposttype_options('myposttype')... |
111,825 | <p>First off, I have been able to successfully implement custom fields within a custom meta box in Wordpress. I understand how this works.</p>
<p>My question is, is there a way for me to add a custom field to an already existing meta box? For instance, I want to add field within Wordpress's "Author" meta box because i... | [
{
"answer_id": 111847,
"author": "edeneye",
"author_id": 29049,
"author_profile": "https://wordpress.stackexchange.com/users/29049",
"pm_score": -1,
"selected": false,
"text": "<p>After some more digging, I came across a solution that works.</p>\n\n<p>I simply remove Wordpress's author m... | 2013/08/27 | [
"https://wordpress.stackexchange.com/questions/111825",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29049/"
] | First off, I have been able to successfully implement custom fields within a custom meta box in Wordpress. I understand how this works.
My question is, is there a way for me to add a custom field to an already existing meta box? For instance, I want to add field within Wordpress's "Author" meta box because it is direc... | I don't know if I'm missing something here but there are several ways to add Html to **Existing core** *Author meta box* and save a custom field -related to the post.
One option is to assign a new callback for the `authordiv` html content, **or** add the html by filtering the output of the author dropdown select list... |
111,827 | <p><strong>My setup is as follows</strong></p>
<p>I hava a custom post type named 'events' and a custom post type named 'genres' which I link with scribu's Posts2Posts plugin. Each event can have multiple genres linked to it.</p>
<p><strong>What I would like to do</strong></p>
<p><em>On an event page</em>, I'd like ... | [
{
"answer_id": 111847,
"author": "edeneye",
"author_id": 29049,
"author_profile": "https://wordpress.stackexchange.com/users/29049",
"pm_score": -1,
"selected": false,
"text": "<p>After some more digging, I came across a solution that works.</p>\n\n<p>I simply remove Wordpress's author m... | 2013/08/27 | [
"https://wordpress.stackexchange.com/questions/111827",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36783/"
] | **My setup is as follows**
I hava a custom post type named 'events' and a custom post type named 'genres' which I link with scribu's Posts2Posts plugin. Each event can have multiple genres linked to it.
**What I would like to do**
*On an event page*, I'd like to show other, related, events based on the genres the cu... | I don't know if I'm missing something here but there are several ways to add Html to **Existing core** *Author meta box* and save a custom field -related to the post.
One option is to assign a new callback for the `authordiv` html content, **or** add the html by filtering the output of the author dropdown select list... |
111,830 | <p>I'm in need to know if the current taxonomy is child or parent. How can i achieve this?</p>
<p>I need it for the condition in if statement. I need to know</p>
<pre><code>if(this is child taxonomy){
}
</code></pre>
<p>Anybody knows how?</p>
| [
{
"answer_id": 111831,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>Use <a href=\"http://codex.wordpress.org/Function_Reference/get_ancestors\" rel=\"nofollow\"><code>get_ances... | 2013/08/27 | [
"https://wordpress.stackexchange.com/questions/111830",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37189/"
] | I'm in need to know if the current taxonomy is child or parent. How can i achieve this?
I need it for the condition in if statement. I need to know
```
if(this is child taxonomy){
}
```
Anybody knows how? | You may be using this piece of code, found in the WordPress support articles and which you can see [here.](http://wordpress.org/support/topic/if-current-taxonomy-has-child-andor-parent) |
111,863 | <p>So I manage a blog of about 15 contributors and 5 editors. I wanted to implement a system so that each time a contributor hits the 'Submit for Review' button, and email is sent to the editors to proof. I've cooked up an action, but it seemed to fire off at "edit post" time and not "submit" time.</p>
<p>My workaroun... | [
{
"answer_id": 111869,
"author": "TomC",
"author_id": 36980,
"author_profile": "https://wordpress.stackexchange.com/users/36980",
"pm_score": 0,
"selected": false,
"text": "<p>I am in a similar situation and the ugly method I came up with was to create a file with the following:</p>\n\n<... | 2013/08/27 | [
"https://wordpress.stackexchange.com/questions/111863",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30841/"
] | So I manage a blog of about 15 contributors and 5 editors. I wanted to implement a system so that each time a contributor hits the 'Submit for Review' button, and email is sent to the editors to proof. I've cooked up an action, but it seemed to fire off at "edit post" time and not "submit" time.
My workaround was to p... | You need [Post Status Transitions](http://codex.wordpress.org/Post_Status_Transitions) actions
```
function notify_me_for_pending( $post ) {
$user_info = get_userdata ($post->post_author);
$strTo = array ('email@example.com');
$strSubject = 'Fstoppers: ' . $user_info->user_nicename . ' submitted a post';
$strM... |
111,871 | <p>I have a custom query returning categories, but I also need to return some pages with a particular post ids. How would I add those? They obviously have no taxonomy and are page post types.</p>
<p>Below is my query so far:</p>
<pre><code>protected function _getPostByCategory($category) {
global $wpdb;
$result = $w... | [
{
"answer_id": 111917,
"author": "epilektric",
"author_id": 36634,
"author_profile": "https://wordpress.stackexchange.com/users/36634",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not a MySQL query expert but a few <code>OR</code> statements might do the trick.</p>\n\n<pre><code>OR... | 2013/08/27 | [
"https://wordpress.stackexchange.com/questions/111871",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24339/"
] | I have a custom query returning categories, but I also need to return some pages with a particular post ids. How would I add those? They obviously have no taxonomy and are page post types.
Below is my query so far:
```
protected function _getPostByCategory($category) {
global $wpdb;
$result = $wpdb->get_results(" SE... | What about using the UNION? Just an example:
```
(SELECT * FROM $wpdb->posts (with JOIN and WHERE as needed))
UNION
(SELECT * FROM $wpdb->posts (with WHERE to select pages))
GROUP BY/ORDER BY
```
The select(s) must be in parenthesis to use an order by for the whole union result.
As a second option, you can use... |
111,931 | <p>I'm creating a list with a few permalinks which I call to with <code><a href="<?php echo get_permalink($id); ?>" title="...</code>. And for the title I want to call <code>the_title_attribute()</code>. But it seems it can only be called within a loop, and not by id. How do I correctly get a title attribute? ... | [
{
"answer_id": 111935,
"author": "Prince Singh",
"author_id": 36972,
"author_profile": "https://wordpress.stackexchange.com/users/36972",
"pm_score": 0,
"selected": false,
"text": "<p>you can use </p>\n\n<pre><code>get_the_title($ID);\n</code></pre>\n\n<p>to get title by id later you can... | 2013/08/28 | [
"https://wordpress.stackexchange.com/questions/111931",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34570/"
] | I'm creating a list with a few permalinks which I call to with `<a href="<?php echo get_permalink($id); ?>" title="...`. And for the title I want to call `the_title_attribute()`. But it seems it can only be called within a loop, and not by id. How do I correctly get a title attribute?
*Note: The reason I want to use ... | hey just look in code and it also support fourth parameter `post`
```
global $post;
the_title_attribute(array('post'=>$post));//post object
```
or
```
global $post;
the_title_attribute(array('post'=>$post->ID));//post id
```
so you can use it like
```
<a href="<?php echo get_permalink($id); ?>" title="<?php ... |
111,937 | <p>I'm using this function in my functions.php to display image caption for faetured images:</p>
<pre><code>function the_post_thumbnail_caption() {
global $post;
$thumbnail_id = get_post_thumbnail_id($post->ID);
$thumbnail_image = get_posts(array('p' => $thumbnail_id, 'post_type' => 'attachment'));
if ($... | [
{
"answer_id": 111939,
"author": "JMau",
"author_id": 31376,
"author_profile": "https://wordpress.stackexchange.com/users/31376",
"pm_score": 2,
"selected": false,
"text": "<p>You could try this :</p>\n\n<pre><code>function the_post_thumbnail_caption() {\n global $post;\n\n $thumbnail_id... | 2013/08/28 | [
"https://wordpress.stackexchange.com/questions/111937",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26413/"
] | I'm using this function in my functions.php to display image caption for faetured images:
```
function the_post_thumbnail_caption() {
global $post;
$thumbnail_id = get_post_thumbnail_id($post->ID);
$thumbnail_image = get_posts(array('p' => $thumbnail_id, 'post_type' => 'attachment'));
if ($thumbnail_image && isse... | I am a "little late" but this solution worked great for me. It will show the div only if the caption is not empty.
```
<?php
$get_description = get_post(get_post_thumbnail_id())->post_excerpt;
the_post_thumbnail();
if(!empty($get_description)){//If description is not empty show the div
echo '<div class="featured_c... |
111,941 | <p>I have a php code. That put the thumbs on the screen. I have this:</p>
<pre><code><?php if (has_post_thumbnail()) : ?>
<div class="image">
<?php
$attachment_id = get_post_thumbnail_id();
$image_attributes = wp_get_attachment_image_src( $attachment_id, 'full' )
?>
<im... | [
{
"answer_id": 111943,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 1,
"selected": false,
"text": "<p>This simply do the same work and also output the <code>alt</code> value:</p>\n\n<pre><code><?php if (has_p... | 2013/08/28 | [
"https://wordpress.stackexchange.com/questions/111941",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17868/"
] | I have a php code. That put the thumbs on the screen. I have this:
```
<?php if (has_post_thumbnail()) : ?>
<div class="image">
<?php
$attachment_id = get_post_thumbnail_id();
$image_attributes = wp_get_attachment_image_src( $attachment_id, 'full' )
?>
<img src="<?php echo $image_attributes... | This simply do the same work and also output the `alt` value:
```
<?php if (has_post_thumbnail()) : ?>
<div class="image"><?php the_post_thumbnail( array(186, 137) ); ?></div>
<?php endif; ?>
```
See [Codex](http://codex.wordpress.org/Function_Reference/the_post_thumbnail) |
111,962 | <p>How would be the array, to insert a post category and subcategory?</p>
<p>Thanks.</p>
| [
{
"answer_id": 111967,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>The argument description in <a href=\"http://codex.wordpress.org/Function_Reference/wp_insert_post\" rel=\"n... | 2013/08/28 | [
"https://wordpress.stackexchange.com/questions/111962",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30777/"
] | How would be the array, to insert a post category and subcategory?
Thanks. | The argument description in [the Codex entry for `wp_insert_post()` has exactly what you need (reformatted)](http://codex.wordpress.org/Function_Reference/wp_insert_post).
```
'post_category' => [ array(<category id>, <...>) ]
//post_category no longer exists, try wp_set_post_terms() for setting a post's categories
... |
111,970 | <p>I am creating a simple framework with theme options. I have divided chunks of code within <code>functions.php</code> and placed it within a specific folder structure.</p>
<p>Now in my main <code>functions.php</code> file, I only have <code>require_once</code> calls to these files. </p>
<p>But for the sake of argum... | [
{
"answer_id": 111990,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 5,
"selected": true,
"text": "<blockquote>\n <p><strong>1.</strong> Does this have effect on WP performance in a visible way ?</p>\n</blockquote>\n... | 2013/08/28 | [
"https://wordpress.stackexchange.com/questions/111970",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36770/"
] | I am creating a simple framework with theme options. I have divided chunks of code within `functions.php` and placed it within a specific folder structure.
Now in my main `functions.php` file, I only have `require_once` calls to these files.
But for the sake of argument - let's say that I'll end up with 20 files to ... | >
> **1.** Does this have effect on WP performance in a visible way ?
>
>
>
*IF* it would have a real affect for some small files, then it would have an affect that has an impact lower than WP: PHP and server performance. Does it really have an affect? Not really. But you can still simply start doing performance t... |
112,005 | <p>I am using this code to add my options inside head section code works but my problem is that if no values are provided my function still echoes an empty <code><style type="text/css"><style></code> into my head. <br/><br/><i>How can I remove style tags if no values are returned?</i> <br/>Thank You!! </p>
... | [
{
"answer_id": 112007,
"author": "eevaa",
"author_id": 37050,
"author_profile": "https://wordpress.stackexchange.com/users/37050",
"pm_score": 1,
"selected": false,
"text": "<p>How about checking whether the item is set beforehand?</p>\n\n<pre><code> foreach( $css as $itm => $value... | 2013/08/28 | [
"https://wordpress.stackexchange.com/questions/112005",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20941/"
] | I am using this code to add my options inside head section code works but my problem is that if no values are provided my function still echoes an empty `<style type="text/css"><style>` into my head.
*How can I remove style tags if no values are returned?*
Thank You!!
```
//Hook into WP head and add our option... | You are using a code a bit *dirty*: foreach is not needed here, and I think you forgot to print the header color (see comment in following code).
After that, if you want to print nothing if you have no customiztion, create an out variable and it's not blank print the styles:
```
add_action('wp_head', 'dynamic_options... |
112,006 | <p>I am trying to create button click counter meta box in a custom post type, but I can't get it to work. What I want to do is when a user click the submit button, then it will do <code>update_post_meta</code> in the background and display the value on the current screen by <code>echo</code> <code>get_post_meta</code> ... | [
{
"answer_id": 112019,
"author": "iEmanuele",
"author_id": 35646,
"author_profile": "https://wordpress.stackexchange.com/users/35646",
"pm_score": 1,
"selected": false,
"text": "<p>Basically an ajax call within WordPress looks like this:</p>\n\n<p><strong>The jQuery / JS script</strong>:... | 2013/08/28 | [
"https://wordpress.stackexchange.com/questions/112006",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32989/"
] | I am trying to create button click counter meta box in a custom post type, but I can't get it to work. What I want to do is when a user click the submit button, then it will do `update_post_meta` in the background and display the value on the current screen by `echo` `get_post_meta` with ajax.
Here is my codes so far:... | First of all output your javascript in like this is a worse practice. So it's a lot better if you create your javascript file and the enqueue it using `wp_enqueue_script` hooked `admin_enqueue_scripts` action.
```
function enqueue_my_ajax( $hook ) {
if( 'post.php' != $hook && 'post-new.php' != $hook ) return;
... |
112,016 | <p>I want to select image from the WordPress 3.5 media uploader. I can get the image URL with the following code, but it gets the full size image. I want to get the thumbnail image url,how can I get that?</p>
<pre><code> var custom_uploader;
$('.upload-image').click(function(e) {
e.preventDefault();
... | [
{
"answer_id": 115027,
"author": "JohnC",
"author_id": 36345,
"author_profile": "https://wordpress.stackexchange.com/users/36345",
"pm_score": -1,
"selected": false,
"text": "<p>You'd have to make a call to the server to run some PHP.</p>\n\n<pre><code>$thumb_src = wp_get_attachment_imag... | 2013/08/28 | [
"https://wordpress.stackexchange.com/questions/112016",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37272/"
] | I want to select image from the WordPress 3.5 media uploader. I can get the image URL with the following code, but it gets the full size image. I want to get the thumbnail image url,how can I get that?
```
var custom_uploader;
$('.upload-image').click(function(e) {
e.preventDefault();
if (custom_upl... | You can debug the result of attachment by :
```
console.log(attachment);
```
and if the thumbnail size available you can retrieve it using :
```
var thumb = attachment.sizes.thumbnail.url;
alert(thumb);
``` |
112,028 | <p>I'm trying to setup the search feature for my website but when I try to search something it keeps taking me to my home page.</p>
<p>I have created searchpage.php and I've added it to my theme, I've taken the URL and added that to a searchform.php.</p>
<p>Here's the code for my searchform:</p>
<pre><code><form ... | [
{
"answer_id": 112030,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 0,
"selected": false,
"text": "<p>Try replacing your search form action url with home_url( '/' ) and setting search name to \"s\" as shown ... | 2013/08/28 | [
"https://wordpress.stackexchange.com/questions/112028",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35858/"
] | I'm trying to setup the search feature for my website but when I try to search something it keeps taking me to my home page.
I have created searchpage.php and I've added it to my theme, I've taken the URL and added that to a searchform.php.
Here's the code for my searchform:
```
<form method="get" id="searchform" ac... | As noted above, when I tried that code I ended up on a server level 404 page. If this is meant to be a standard WordPress search ( ia m not sure if it is) you need to be using `name="s"` and not `name="q"`. WordPress uses the `s` `GET` variable for a search.
The following submits to whatever page I specify in my insta... |
112,056 | <p>Im trying to use </p>
<pre><code>remove_action( 'admin_notices', 'woothemes_updater_notice' );
</code></pre>
<p>In a plugin to keep from editing the themes functions.php file however the code isnt being executed. Do i need to wrap this in something to get it to work from the plugin files?</p>
| [
{
"answer_id": 112057,
"author": "Noob Theory",
"author_id": 31195,
"author_profile": "https://wordpress.stackexchange.com/users/31195",
"pm_score": 1,
"selected": false,
"text": "<p>Found the answer just after posting. If anyone is having the same issue i solved it with this.</p>\n\n<pr... | 2013/08/28 | [
"https://wordpress.stackexchange.com/questions/112056",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31195/"
] | Im trying to use
```
remove_action( 'admin_notices', 'woothemes_updater_notice' );
```
In a plugin to keep from editing the themes functions.php file however the code isnt being executed. Do i need to wrap this in something to get it to work from the plugin files? | Make sure you remove the action *after* the theme has added it. And use the same priority.
A rather safe way is using the same action you want to clean up:
```
add_action( 'admin_notices', 'remove_woothemes_updater_notice', 0 );
function remove_woothemes_updater_notice()
{
remove_action( 'admin_notices', 'woothe... |
112,081 | <p>I would like to insert an iframe with WordPress content inside a post. I explain myself. I have two things: a post and a presentation. In the <code>the_content()</code> WordPress filter, I add my iframe to the $content. This iframe has a src pointing to a custom .php file, and inside this .php I want to have access ... | [
{
"answer_id": 112112,
"author": "Dave Ross",
"author_id": 3851,
"author_profile": "https://wordpress.stackexchange.com/users/3851",
"pm_score": 2,
"selected": false,
"text": "<p>There's a file in the root of your WordPress installation called <code>wp-load.php</code>. If you include tha... | 2013/08/29 | [
"https://wordpress.stackexchange.com/questions/112081",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36316/"
] | I would like to insert an iframe with WordPress content inside a post. I explain myself. I have two things: a post and a presentation. In the `the_content()` WordPress filter, I add my iframe to the $content. This iframe has a src pointing to a custom .php file, and inside this .php I want to have access to my loop but... | There's a file in the root of your WordPress installation called `wp-load.php`. If you include that file at the top of your .php file, it will bootstrap enough of WordPress that you'll be able to access its API and execute your shortcodes.
**However, there's a better way to do it.**
See, with the approach you're usin... |
112,085 | <p>I have a simple jQuery script to enable an image mouseover hover effect that I want to use on my WP custom page template but it isn't yet working for me and I assume it is not linking to jQuery. The hover image does not display.</p>
<p>Here is part of the page template code (theme=Twenty_Eleven)</p>
<pre><code><... | [
{
"answer_id": 112089,
"author": "Prince Singh",
"author_id": 36972,
"author_profile": "https://wordpress.stackexchange.com/users/36972",
"pm_score": 0,
"selected": false,
"text": "<p>replace $ sign with jQuery example -\n <code>$(document).ready(function()</code> </p>\n\n<p>should be ... | 2013/08/29 | [
"https://wordpress.stackexchange.com/questions/112085",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5822/"
] | I have a simple jQuery script to enable an image mouseover hover effect that I want to use on my WP custom page template but it isn't yet working for me and I assume it is not linking to jQuery. The hover image does not display.
Here is part of the page template code (theme=Twenty\_Eleven)
```
<?php
/**
* Template N... | Probably there are a lot of questions/answers here in wpse that explain this kind of issues and the use of jquery and other js in wordpress.
However,
1. In wordpress **never** put javascripts in template files. Javascript should be in separate .js files.
2. The javascript should be putted in the templates using `wp_r... |
112,105 | <p>I have a hierarchical CPT with the following structure:</p>
<pre><code>- parent item 1
- child item 1
- child item 2
- child item 3
- child item 4
- child item 5
- parent item 2
- child item 1
- child item 2
- child item 3
- child item 4
- child item 5
</code></pre>
<p>each child item... | [
{
"answer_id": 114281,
"author": "Eugenious",
"author_id": 37096,
"author_profile": "https://wordpress.stackexchange.com/users/37096",
"pm_score": 0,
"selected": false,
"text": "<p>If you want to sort hierarchical posts, then the straightforward way to do this is to use the \"order\" fie... | 2013/08/29 | [
"https://wordpress.stackexchange.com/questions/112105",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/403/"
] | I have a hierarchical CPT with the following structure:
```
- parent item 1
- child item 1
- child item 2
- child item 3
- child item 4
- child item 5
- parent item 2
- child item 1
- child item 2
- child item 3
- child item 4
- child item 5
```
each child item has a meta key called "se... | As I couldn't find any filter to override the `WP_Posts_List_Table` class, I propose a quite hacky solution by doing this:
1. Query only parents in `pre_get_posts`;
2. Query their children on `wp` and change `$wp_query->posts` accordingly.
This might need some more work as I'm probably breaking pagination numbers or ... |
112,107 | <p>I'd like to use blog.example.com as the base for my blog posts, e.g. <a href="http://blog.example.com/2013/08/29/sample-post/" rel="noreferrer">http://blog.example.com/2013/08/29/sample-post/</a> and www.example.com for my pages, e.g. www.example.com/about-me/</p>
<p>Is there an easy way to do this? I tried with cr... | [
{
"answer_id": 249191,
"author": "Pim",
"author_id": 50432,
"author_profile": "https://wordpress.stackexchange.com/users/50432",
"pm_score": 1,
"selected": false,
"text": "<p>I believe the only way is to use <code>mod_rewrite</code> in your <code>.htaccess</code> to turn a fixed url; say... | 2013/08/29 | [
"https://wordpress.stackexchange.com/questions/112107",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5199/"
] | I'd like to use blog.example.com as the base for my blog posts, e.g. <http://blog.example.com/2013/08/29/sample-post/> and www.example.com for my pages, e.g. www.example.com/about-me/
Is there an easy way to do this? I tried with creating a network but that gives me two WordPress installations, both with posts and pag... | I might have a solution for you.
First steps:
1. Within your domain's DNS manager you need to create a CNAME record. The name would be **blog** and the hostname would be your **domain name**. This is necessary because the browser needs to know where to point the subdomain **blog.mydomain.com to**;
2. Second, you need... |
112,129 | <p>I want to get details about a plugin hosted on WordPress.org Repository by making a call to API at <a href="http://api.wordpress.org/plugins/info/1.0/" rel="nofollow">http://api.wordpress.org/plugins/info/1.0/</a></p>
<p>I have pasted below the code I used and the output. I am not good with PHP and just wanted to k... | [
{
"answer_id": 249191,
"author": "Pim",
"author_id": 50432,
"author_profile": "https://wordpress.stackexchange.com/users/50432",
"pm_score": 1,
"selected": false,
"text": "<p>I believe the only way is to use <code>mod_rewrite</code> in your <code>.htaccess</code> to turn a fixed url; say... | 2013/08/29 | [
"https://wordpress.stackexchange.com/questions/112129",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18389/"
] | I want to get details about a plugin hosted on WordPress.org Repository by making a call to API at <http://api.wordpress.org/plugins/info/1.0/>
I have pasted below the code I used and the output. I am not good with PHP and just wanted to know the way to retrieve and output just one piece of information from the array ... | I might have a solution for you.
First steps:
1. Within your domain's DNS manager you need to create a CNAME record. The name would be **blog** and the hostname would be your **domain name**. This is necessary because the browser needs to know where to point the subdomain **blog.mydomain.com to**;
2. Second, you need... |
112,130 | <p>I got my WordPress 3.6 installation running using a theme I have bought. When I'm using my theme the console says:</p>
<pre><code>GET ...xyz.de/landing/wp-includes/js/jquery/jquery-1.10.2.min.map 404 (Not Found)
</code></pre>
<p>This error does not appear when using the default theme. This seems like a broken impo... | [
{
"answer_id": 112133,
"author": "Dave Ross",
"author_id": 3851,
"author_profile": "https://wordpress.stackexchange.com/users/3851",
"pm_score": 0,
"selected": false,
"text": "<p>WordPress ships with a minified version of jQuery that includes a <code>sourceMappingURL</code> directive whi... | 2013/08/29 | [
"https://wordpress.stackexchange.com/questions/112130",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36984/"
] | I got my WordPress 3.6 installation running using a theme I have bought. When I'm using my theme the console says:
```
GET ...xyz.de/landing/wp-includes/js/jquery/jquery-1.10.2.min.map 404 (Not Found)
```
This error does not appear when using the default theme. This seems like a broken import of a jQuery file. The s... | This is a known issue for WordPress 3.6. There is already a [ticket](http://core.trac.wordpress.org/ticket/24994) in the WordPress bug tracker. A patch can be found [there](http://core.trac.wordpress.org/attachment/ticket/24994/24994.patch) too but I haven't tried it yet. |