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 |
|---|---|---|---|---|---|---|
135,921 | <p>This is the code from the codex most commonly used for sidebar menus. It displays the child pages of the top level ancestor and the ancestor itself.</p>
<p>There is one thing about this code I would like to change - I don't want the top level ancestor displayed if it has no children! It doesn't make much sense to h... | [
{
"answer_id": 135923,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 0,
"selected": false,
"text": "<p>This may not be exactly what you're looking for but I use a Frankenstein approach, it gets the job done:</p... | 2014/02/25 | [
"https://wordpress.stackexchange.com/questions/135921",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5205/"
] | This is the code from the codex most commonly used for sidebar menus. It displays the child pages of the top level ancestor and the ancestor itself.
There is one thing about this code I would like to change - I don't want the top level ancestor displayed if it has no children! It doesn't make much sense to have a one ... | Personally, I think this is the neatest, least intensive (database querying) solution:
```
<?php
$parentid = $post->post_parent ? @ array_pop( get_post_ancestors( $post ) ) : $post->ID;
$children = wp_list_pages(
array(
'child_of' => $parentid,
'title_li' => '',
'echo' => false,
)
)... |
135,931 | <p>I built a plugin for wordpress with custom post types and somewhere along the line I realized that I had to rebuild the way slugs are generated. Originally, I had the cpt making default slugs like new-post-1, new-post-2, etc. I realized this was silly and rewrote the naming convention to create a slug from the pos... | [
{
"answer_id": 135923,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 0,
"selected": false,
"text": "<p>This may not be exactly what you're looking for but I use a Frankenstein approach, it gets the job done:</p... | 2014/02/25 | [
"https://wordpress.stackexchange.com/questions/135931",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37054/"
] | I built a plugin for wordpress with custom post types and somewhere along the line I realized that I had to rebuild the way slugs are generated. Originally, I had the cpt making default slugs like new-post-1, new-post-2, etc. I realized this was silly and rewrote the naming convention to create a slug from the post tit... | Personally, I think this is the neatest, least intensive (database querying) solution:
```
<?php
$parentid = $post->post_parent ? @ array_pop( get_post_ancestors( $post ) ) : $post->ID;
$children = wp_list_pages(
array(
'child_of' => $parentid,
'title_li' => '',
'echo' => false,
)
)... |
135,955 | <p>Im creating custom theme options and Im getting this PHP error: Warning: Illegal string offset in ... on line 75</p>
<pre><code>// adding the page to menu
add_menu_page('Theme Options', 'Theme Options', 'manage_options', 'rm-options', 'rm_display_options_page');
// form to display options
<form method="post" ac... | [
{
"answer_id": 135957,
"author": "Morgan Estes",
"author_id": 26317,
"author_profile": "https://wordpress.stackexchange.com/users/26317",
"pm_score": 2,
"selected": false,
"text": "<p>The code you posted has a <strong>major flaw</strong>*: it mixes HTML and PHP without properly setting t... | 2014/02/25 | [
"https://wordpress.stackexchange.com/questions/135955",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/41331/"
] | Im creating custom theme options and Im getting this PHP error: Warning: Illegal string offset in ... on line 75
```
// adding the page to menu
add_menu_page('Theme Options', 'Theme Options', 'manage_options', 'rm-options', 'rm_display_options_page');
// form to display options
<form method="post" action="options.php... | The code you posted has a **major flaw**\*: it mixes HTML and PHP without properly setting them apart. This code chunk has a PHP function call followed by an HTML string, but since there's nothing telling the file that it should be treated as HTML, the parser says "Hey, `<form` isn't anything I recognize. I'm outta her... |
135,960 | <p>I'm getting a 502 Bad Gateway error for wp-admin/admin-ajax.php -- this is a WP site, hosted on WebFaction, which is using nginx.</p>
<p>Where it most obviously crops up is when adding a new post or page, clicking on "Insert Media", nothing in the library shows up. Inspector console is filled with these: </p>
<pre... | [
{
"answer_id": 331277,
"author": "Tharindu Wickramasinghe",
"author_id": 162890,
"author_profile": "https://wordpress.stackexchange.com/users/162890",
"pm_score": 2,
"selected": false,
"text": "<p>I had similar problem on wordpress site. add these lines inside <code>http</code> block of ... | 2014/02/26 | [
"https://wordpress.stackexchange.com/questions/135960",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48164/"
] | I'm getting a 502 Bad Gateway error for wp-admin/admin-ajax.php -- this is a WP site, hosted on WebFaction, which is using nginx.
Where it most obviously crops up is when adding a new post or page, clicking on "Insert Media", nothing in the library shows up. Inspector console is filled with these:
```
POST http://li... | I had similar problem on wordpress site. add these lines inside `http` block of `/etc/nginx/nginx.conf` file.
```
fastcgi_temp_file_write_size 10m;
fastcgi_busy_buffers_size 512k;
fastcgi_buffer_size 512k;
fastcgi_buffers 16 512k;
```
If it still not working also add this line
```
client_max_body_size 50M;
``` |
136,010 | <p>For some reason whenever I add a widget to the footer of my site, it moves to the center of the page - but only in Chrome and Safari. Firefox the footer stays put at the bottom.</p>
<p>The only way I can think to change this is to increase the padding-top size. This puts the footer back at the bottom and looks fine... | [
{
"answer_id": 136008,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 2,
"selected": true,
"text": "<p>Your theme is trying to retrieve data from Twitter and store it. It is failing to do so for whatever reason. </p>\n... | 2014/02/26 | [
"https://wordpress.stackexchange.com/questions/136010",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48140/"
] | For some reason whenever I add a widget to the footer of my site, it moves to the center of the page - but only in Chrome and Safari. Firefox the footer stays put at the bottom.
The only way I can think to change this is to increase the padding-top size. This puts the footer back at the bottom and looks fine in Safari... | Your theme is trying to retrieve data from Twitter and store it. It is failing to do so for whatever reason.
Contact the author of the theme and have them fix it. |
136,017 | <p>I use the bellow function (thanks to @helgatheviking!) to <a href="https://wordpress.stackexchange.com/a/44707/25187">exclude categories</a> from the wordpress loop. It works very well - posts of selected categories are excluded from the loop on the main blog listing page, from category listing pages and from archiv... | [
{
"answer_id": 136023,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 2,
"selected": false,
"text": "<p>The original author isn't quite right in saying \"which is merely the more elegant way to write\".</p>\n\n... | 2014/02/26 | [
"https://wordpress.stackexchange.com/questions/136017",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25187/"
] | I use the bellow function (thanks to @helgatheviking!) to [exclude categories](https://wordpress.stackexchange.com/a/44707/25187) from the wordpress loop. It works very well - posts of selected categories are excluded from the loop on the main blog listing page, from category listing pages and from archives, **but not*... | I excluded my selected categories ~~from everywhere with the [Advanced Category Excluder](https://wordpress.org/plugins/advanced-category-excluder/) (ACE) plugin, except from Categories widget - here helped the @Brad Dalton code. ACE has an own Recent Comments widget that hides excluded categories, but here was a minor... |
136,054 | <p>My client needs to add unique blocks of javascript to certain pages in order to track visitors. How do I go about doing this?</p>
<p>At first I tried to use a custom field but the field stripped out everything before outputting it to the page so I got an empty result. Then I installed an Advanced Custom Fields exte... | [
{
"answer_id": 136063,
"author": "madlabmg",
"author_id": 48164,
"author_profile": "https://wordpress.stackexchange.com/users/48164",
"pm_score": 0,
"selected": false,
"text": "<p>You could use conditional statements to put it in the footer of the page. Find the numerical identifiers of ... | 2014/02/26 | [
"https://wordpress.stackexchange.com/questions/136054",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31414/"
] | My client needs to add unique blocks of javascript to certain pages in order to track visitors. How do I go about doing this?
At first I tried to use a custom field but the field stripped out everything before outputting it to the page so I got an empty result. Then I installed an Advanced Custom Fields extension that... | Use conditional tags.
Change the 5th parameter to load in the footer.
Change `get_stylesheet_directory_uri()` to `get_template_directory_uri()` for use in parent themes.
```
add_action( 'wp_enqueue_scripts', 'add_tracking_scripts' );
function add_tracking_scripts() {
if ( is_page('slug') ) {
wp_register_script(
... |
136,058 | <p>I've got the following code, which cleans up a lot of stuff that is not going to be used within the admin area:</p>
<pre><code>add_action( 'admin_menu', 'my_remove_menu_pages' );
function my_remove_menu_pages() {
remove_menu_page( 'edit.php' ); //Posts
remove_menu_page( 'upload.php' ); ... | [
{
"answer_id": 136061,
"author": "hereswhatidid",
"author_id": 3032,
"author_profile": "https://wordpress.stackexchange.com/users/3032",
"pm_score": 4,
"selected": false,
"text": "<p>You probably need to set the add_action <a href=\"http://codex.wordpress.org/Function_Reference/add_actio... | 2014/02/26 | [
"https://wordpress.stackexchange.com/questions/136058",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33541/"
] | I've got the following code, which cleans up a lot of stuff that is not going to be used within the admin area:
```
add_action( 'admin_menu', 'my_remove_menu_pages' );
function my_remove_menu_pages() {
remove_menu_page( 'edit.php' ); //Posts
remove_menu_page( 'upload.php' ); //Me... | You need to use the right *hooks* (which are not always the same as the URLs/slugs), and it doesn't hurt to use a hook that runs later (e.g., `admin_init`):
```
add_action( 'admin_init', 'wpse_136058_remove_menu_pages' );
function wpse_136058_remove_menu_pages() {
remove_menu_page( 'edit.php?post_type=acf' );
... |
136,062 | <p>In the <code>profile.php</code> admin page there is a checkbox for the <em>Toolbar</em>: <strong>Show Toolbar when viewing site</strong>.</p>
<p>I can't seem to find where this option is stored in the database. I would have thought it would be in the <code>wp_usermeta</code> table ... but I don't see it.</p>
<p>M... | [
{
"answer_id": 136061,
"author": "hereswhatidid",
"author_id": 3032,
"author_profile": "https://wordpress.stackexchange.com/users/3032",
"pm_score": 4,
"selected": false,
"text": "<p>You probably need to set the add_action <a href=\"http://codex.wordpress.org/Function_Reference/add_actio... | 2014/02/26 | [
"https://wordpress.stackexchange.com/questions/136062",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14002/"
] | In the `profile.php` admin page there is a checkbox for the *Toolbar*: **Show Toolbar when viewing site**.
I can't seem to find where this option is stored in the database. I would have thought it would be in the `wp_usermeta` table ... but I don't see it.
My goal is to set the default value of this to "off" for new ... | You need to use the right *hooks* (which are not always the same as the URLs/slugs), and it doesn't hurt to use a hook that runs later (e.g., `admin_init`):
```
add_action( 'admin_init', 'wpse_136058_remove_menu_pages' );
function wpse_136058_remove_menu_pages() {
remove_menu_page( 'edit.php?post_type=acf' );
... |
136,079 | <p>I'm building a theme for the first time, using Bootstrap 3 integrated with Wordpress to do so. I have a carousel partially working. Right now it shows the slides in reverse order, i.e. Slide 3, Slide 2, Slide 1. Then it breaks and goes to a blank screen. </p>
<p>This is the code I'm using. Any ideas why this i... | [
{
"answer_id": 157234,
"author": "Nathan",
"author_id": 57639,
"author_profile": "https://wordpress.stackexchange.com/users/57639",
"pm_score": 1,
"selected": false,
"text": "<p>I solved it with a custom query </p>\n\n<pre><code> $args = array(\n'post_type' => 'slide',\n'orderby' =>... | 2014/02/26 | [
"https://wordpress.stackexchange.com/questions/136079",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44093/"
] | I'm building a theme for the first time, using Bootstrap 3 integrated with Wordpress to do so. I have a carousel partially working. Right now it shows the slides in reverse order, i.e. Slide 3, Slide 2, Slide 1. Then it breaks and goes to a blank screen.
This is the code I'm using. Any ideas why this is happening or ... | I solved it with a custom query
```
$args = array(
'post_type' => 'slide',
'orderby' => 'date',
'order' => 'ASC'
);
$i=1;
$slide_query = new WP_Query($args);
while ( $slide_query->have_posts() ) : $slide_query->the_post();
``` |
136,091 | <h2>Question</h2>
<p>Since I am using multiple instances of <code>home_url()</code> in one page template, I was curious if the following method would speed up my page load time. My method is to store the output of <code>home_url()</code> within a variable and then call that variable each time, rather than using <code>... | [
{
"answer_id": 136093,
"author": "Cameron Hurd",
"author_id": 35566,
"author_profile": "https://wordpress.stackexchange.com/users/35566",
"pm_score": 0,
"selected": false,
"text": "<p>You're absolutely right in your assumption. Look at the actual definition of <code>get_home_url()</code>... | 2014/02/27 | [
"https://wordpress.stackexchange.com/questions/136091",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3420/"
] | Question
--------
Since I am using multiple instances of `home_url()` in one page template, I was curious if the following method would speed up my page load time. My method is to store the output of `home_url()` within a variable and then call that variable each time, rather than using `home_url()` each time.
Motiva... | If you look at [the source for the `home_url()` function](https://core.trac.wordpress.org/browser/tags/3.8.1/src/wp-includes/link-template.php#L1968), you'll note a small series of function calls eventually invoking `get_option()`. As explained in [this WPSE Answer](https://wordpress.stackexchange.com/questions/102555/... |
136,101 | <p>I have simple post with a shortcode:</p>
<pre><code>[xx]http://harrix.org/1.txt[xx]
</code></pre>
<p>And an external file which has the content containing a WordPress shortcode:</p>
<pre><code>[strong] g[/strong]
</code></pre>
<p>I try add my own tag to load the external file:</p>
<pre><code><?
add_filter('t... | [
{
"answer_id": 136093,
"author": "Cameron Hurd",
"author_id": 35566,
"author_profile": "https://wordpress.stackexchange.com/users/35566",
"pm_score": 0,
"selected": false,
"text": "<p>You're absolutely right in your assumption. Look at the actual definition of <code>get_home_url()</code>... | 2014/02/27 | [
"https://wordpress.stackexchange.com/questions/136101",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48229/"
] | I have simple post with a shortcode:
```
[xx]http://harrix.org/1.txt[xx]
```
And an external file which has the content containing a WordPress shortcode:
```
[strong] g[/strong]
```
I try add my own tag to load the external file:
```
<?
add_filter('the_content', 'WorkWithTags');
function WorkWithTags($content){
... | If you look at [the source for the `home_url()` function](https://core.trac.wordpress.org/browser/tags/3.8.1/src/wp-includes/link-template.php#L1968), you'll note a small series of function calls eventually invoking `get_option()`. As explained in [this WPSE Answer](https://wordpress.stackexchange.com/questions/102555/... |
136,106 | <p>I have been trying to add a checkbox into the theme customizer. I have a checkbox added using this code in my functions.php</p>
<pre><code>function theme_customizer_register_checkbox($wp_customize) {
$wp_customize->add_section( 'savior_global_options', array(
'title' => 'Global Options',
) );
$... | [
{
"answer_id": 136116,
"author": "Dylan",
"author_id": 41351,
"author_profile": "https://wordpress.stackexchange.com/users/41351",
"pm_score": 0,
"selected": false,
"text": "<p>I'm pretty sure your theme modification setting isn't displaying as you're saving it as an option. You're setti... | 2014/02/27 | [
"https://wordpress.stackexchange.com/questions/136106",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14761/"
] | I have been trying to add a checkbox into the theme customizer. I have a checkbox added using this code in my functions.php
```
function theme_customizer_register_checkbox($wp_customize) {
$wp_customize->add_section( 'savior_global_options', array(
'title' => 'Global Options',
) );
$wp_customize->add_se... | I was able to solve this. Here is the code that got the checkbox working.
```
function theme_customizer_register_checkbox($wp_customize) {
$wp_customize->add_section( 'global_options', array(
'title' => 'Global Options',
) );
$wp_customize->add_setting( 'show_supporters', array(
'default' => true... |
136,128 | <p>A client of mine wants to create a simple "related posts" loop that shows 6 of the most recent posts that match the current post's category. The issue is that every one of their posts have the same parent category and then are organised using children of that category so simply using <code>get_the_category</code> as... | [
{
"answer_id": 136135,
"author": "sri",
"author_id": 34200,
"author_profile": "https://wordpress.stackexchange.com/users/34200",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://wordpress.org/support/topic/display-every-grandchildren\" rel=\"nofollow noreferrer\">Display ev... | 2014/02/27 | [
"https://wordpress.stackexchange.com/questions/136128",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33310/"
] | A client of mine wants to create a simple "related posts" loop that shows 6 of the most recent posts that match the current post's category. The issue is that every one of their posts have the same parent category and then are organised using children of that category so simply using `get_the_category` as I have been d... | [Display every grandchildren](http://wordpress.org/support/topic/display-every-grandchildren) on wordpress support forum seems pretty close.
Here is the solution that was proposed:
```
<ul>
<?php $all = get_pages(); //You could use $args to retrieve posts how you want.
foreach($all as $all) {
if($all->post_parent... |
136,145 | <p>I have a wordpress autoblog.. I need to delete first four characters from each single post title automatically.. How can I achieve it?</p>
| [
{
"answer_id": 136146,
"author": "anu",
"author_id": 490,
"author_profile": "https://wordpress.stackexchange.com/users/490",
"pm_score": 2,
"selected": false,
"text": "<p>You can use 'the_title' filter (<a href=\"http://codex.wordpress.org/Plugin_API/Filter_Reference/the_title%29\" rel=\... | 2014/02/27 | [
"https://wordpress.stackexchange.com/questions/136145",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48252/"
] | I have a wordpress autoblog.. I need to delete first four characters from each single post title automatically.. How can I achieve it? | You can use 'the\_title' filter ([Codex link](http://codex.wordpress.org/Plugin_API/Filter_Reference/the_title%29))
```
add_filter( 'the_title', 'lose_four_chars');
function lose_four_chars($title) {
if ( is_single()) {
return substr($title, 4);
} else {
return $title;
}
}
``` |
136,161 | <p>I have a custom post type called "exhibitions" that uses the native "category" taxonomy. I have three categories: Current, Past, and Featured. Posts get marked either Current or Past and some are also marked as Featured.</p>
<p>I want my next/prev links on single pages to exclude the 'featured' category (tag_ID=21)... | [
{
"answer_id": 136146,
"author": "anu",
"author_id": 490,
"author_profile": "https://wordpress.stackexchange.com/users/490",
"pm_score": 2,
"selected": false,
"text": "<p>You can use 'the_title' filter (<a href=\"http://codex.wordpress.org/Plugin_API/Filter_Reference/the_title%29\" rel=\... | 2014/02/27 | [
"https://wordpress.stackexchange.com/questions/136161",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43008/"
] | I have a custom post type called "exhibitions" that uses the native "category" taxonomy. I have three categories: Current, Past, and Featured. Posts get marked either Current or Past and some are also marked as Featured.
I want my next/prev links on single pages to exclude the 'featured' category (tag\_ID=21) so that ... | You can use 'the\_title' filter ([Codex link](http://codex.wordpress.org/Plugin_API/Filter_Reference/the_title%29))
```
add_filter( 'the_title', 'lose_four_chars');
function lose_four_chars($title) {
if ( is_single()) {
return substr($title, 4);
} else {
return $title;
}
}
``` |
136,166 | <p>I'd like to add a new user to the WordPress user table. The code for wp_create_user works fine but it is adding the user incrementally to the next available ID in the user table. </p>
<p>Instead, <strong>I want to create the user and assign it to a particular user ID</strong>. The user ID is already available (exte... | [
{
"answer_id": 136169,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>Not with <code>wp_create_user()</code>. Check the source:</p>\n\n<blockquote>\n<pre><code>1518 function wp_... | 2014/02/27 | [
"https://wordpress.stackexchange.com/questions/136166",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47326/"
] | I'd like to add a new user to the WordPress user table. The code for wp\_create\_user works fine but it is adding the user incrementally to the next available ID in the user table.
Instead, **I want to create the user and assign it to a particular user ID**. The user ID is already available (externally) and I want th... | `wp_insert_user` will not create a non-existing user with a set ID, it will return an error.
The way to do this would be to first do:
```
global $wpdb;
$wpdb->insert( $wpdb->users, array( 'ID' => 136166 ) );
wp_insert_user( ... );
```
The code above will first create an empty user row with the set ID (it will fai... |
136,179 | <p>After multiple research I didn't find the correct answer to my question.</p>
<p>I just need to order my custom post type by date and then by time (format: 18:00).</p>
<p>Here's what I tried: <a href="http://pastebin.com/BRR6h08j" rel="nofollow">http://pastebin.com/BRR6h08j</a></p>
<p>It orders well by the date bu... | [
{
"answer_id": 136169,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>Not with <code>wp_create_user()</code>. Check the source:</p>\n\n<blockquote>\n<pre><code>1518 function wp_... | 2014/02/27 | [
"https://wordpress.stackexchange.com/questions/136179",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25811/"
] | After multiple research I didn't find the correct answer to my question.
I just need to order my custom post type by date and then by time (format: 18:00).
Here's what I tried: <http://pastebin.com/BRR6h08j>
It orders well by the date but not by the time. And I don't need to hide events that occured.
If someone can... | `wp_insert_user` will not create a non-existing user with a set ID, it will return an error.
The way to do this would be to first do:
```
global $wpdb;
$wpdb->insert( $wpdb->users, array( 'ID' => 136166 ) );
wp_insert_user( ... );
```
The code above will first create an empty user row with the set ID (it will fai... |
136,181 | <p>Is it possible to display the content of all the pages under a single page??
Like, I have Home, About and Contact us pages. I want all of its contents to display under a single frontend page. Is it possible and how can we do it?</p>
| [
{
"answer_id": 136546,
"author": "thegoose",
"author_id": 48407,
"author_profile": "https://wordpress.stackexchange.com/users/48407",
"pm_score": 0,
"selected": false,
"text": "<p>Try placing the following code under index.php for each post, where PAGE_ID_GOES_HERE is the ID number of th... | 2014/02/27 | [
"https://wordpress.stackexchange.com/questions/136181",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45479/"
] | Is it possible to display the content of all the pages under a single page??
Like, I have Home, About and Contact us pages. I want all of its contents to display under a single frontend page. Is it possible and how can we do it? | This is really pretty trivial to implement. [A few minutes with the Codex should solve the problem, really.](http://codex.wordpress.org/Class_Reference/WP_Query)
```
$args = array(
'post_type' => 'page',
'posts_per_page' => -1,
);
$q = new WP_Query($args);
if ($q->have_posts()) {
while ($q->have_posts()) {
$... |
136,190 | <p>I've tried to echo excerpts in <code>wp_list_pages</code> with the code below. It works, but only for one of the child pages. How would I echo the excerpt and title for each child page?</p>
<pre><code><?php
$children = wp_list_pages('title_li=&depth=1&child_of='.$post->ID.'&echo=0');
if ($children... | [
{
"answer_id": 136201,
"author": "Steven Jones",
"author_id": 24124,
"author_profile": "https://wordpress.stackexchange.com/users/24124",
"pm_score": 2,
"selected": false,
"text": "<p><code>wp_list_pages()</code> is for displaying a list of pages. It looks like you want to do more with i... | 2014/02/27 | [
"https://wordpress.stackexchange.com/questions/136190",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5205/"
] | I've tried to echo excerpts in `wp_list_pages` with the code below. It works, but only for one of the child pages. How would I echo the excerpt and title for each child page?
```
<?php
$children = wp_list_pages('title_li=&depth=1&child_of='.$post->ID.'&echo=0');
if ($children) { ?>
<h2>
<?php echo $childre... | If you want to make use of all the nifty filters for the title and excerpt/content (and why would you not want that?) you should loop through a custom query instead of using `get_pages` and the pages' plain contents:
```
<?php
$args = array(
'post_type' => 'page',
'post_status' => 'publish',
'posts_per_pag... |
136,220 | <p>I am in need to remove just this line <code><meta name=robots content="noindex,follow"/></code> from <code>wp_head</code> but can't find the right hook to use it with <code>remove_action()</code>.</p>
<pre><code><meta name=robots content="noindex,follow"/>
</code></pre>
<p>Basically what I want to achi... | [
{
"answer_id": 136225,
"author": "bosco",
"author_id": 25324,
"author_profile": "https://wordpress.stackexchange.com/users/25324",
"pm_score": 0,
"selected": false,
"text": "<p>I would recommend simply unchecking the \"Discourage search engines from indexing this site\" box from <code>Se... | 2014/02/27 | [
"https://wordpress.stackexchange.com/questions/136220",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44982/"
] | I am in need to remove just this line `<meta name=robots content="noindex,follow"/>` from `wp_head` but can't find the right hook to use it with `remove_action()`.
```
<meta name=robots content="noindex,follow"/>
```
Basically what I want to achieve is to remove just this line from the header but just for the search... | I got it, the output is controlled by the [WordPress SEO](http://wordpress.org/plugins/wordpress-seo/) plugin as this is enabled in the site, so I had to tiny hard code in the plugin file [class-frontend.php](https://plugins.trac.wordpress.org/browser/wordpress-seo/trunk/frontend/class-frontend.php#L552)
Obviously, I ... |
136,221 | <p>I call a lot of images with <code>wp_get_attachment_image_src()</code> and would like to off load those images to a CDN. </p>
<p>Is there a filter to grab the URL and change it?</p>
| [
{
"answer_id": 136234,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>No, not strictly. You can <a href=\"https://core.trac.wordpress.org/browser/tags/3.8.1/src/wp-includes/media.... | 2014/02/27 | [
"https://wordpress.stackexchange.com/questions/136221",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2832/"
] | I call a lot of images with `wp_get_attachment_image_src()` and would like to off load those images to a CDN.
Is there a filter to grab the URL and change it? | No, not strictly. You can [check the source](https://core.trac.wordpress.org/browser/tags/3.8.1/src/wp-includes/media.php#L0) and see that there is no hook that would let you alter the URL.
You should also notice this interesting bit of code:
```
512 if ( $image = image_downsize($attachment_id, $size) )
513 ... |
136,270 | <p>I'm (locally) building a custom theme.</p>
<p>So far I have:</p>
<ul>
<li>index.php</li>
<li>single.php</li>
<li>page.php</li>
<li>custom page template called about-page.php</li>
<li>two different headers: one for default use and one for the single.php</li>
</ul>
<p>NO functions.php;
NO custom taxonomy;
Permalink... | [
{
"answer_id": 136280,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 1,
"selected": false,
"text": "<p>Your structures is completely wrong. Remove the template name from your <code>index.php</code> and <cod... | 2014/02/28 | [
"https://wordpress.stackexchange.com/questions/136270",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48150/"
] | I'm (locally) building a custom theme.
So far I have:
* index.php
* single.php
* page.php
* custom page template called about-page.php
* two different headers: one for default use and one for the single.php
NO functions.php;
NO custom taxonomy;
Permalink settings > Common settings : default
My index.php has a list ... | Your structures is completely wrong. Remove the template name from your `index.php` and `single.php` templates. You only should use those if you create a custom `page.php` template to let wordpress know it is a custom page. This should apply to your `about-page.php`, which is also wrongly named, it should be `page-abou... |
136,271 | <p>I am working on a simple front end image upload in Wordpress. With this piece of code I can upload to the wordpress media section but I only upload the name and url of the file then, no image.</p>
<p>Does anyone know what I need to do to upload the image also?</p>
<p>My form:</p>
<pre><code><form id="dash_acti... | [
{
"answer_id": 136406,
"author": "James Austen",
"author_id": 48312,
"author_profile": "https://wordpress.stackexchange.com/users/48312",
"pm_score": 3,
"selected": true,
"text": "<p>The <a href=\"http://codex.wordpress.org/Function_Reference/wp_insert_attachment\" rel=\"nofollow\">WordP... | 2014/02/28 | [
"https://wordpress.stackexchange.com/questions/136271",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25834/"
] | I am working on a simple front end image upload in Wordpress. With this piece of code I can upload to the wordpress media section but I only upload the name and url of the file then, no image.
Does anyone know what I need to do to upload the image also?
My form:
```
<form id="dash_action" method="post" enctype="mult... | The [WordPress codex](http://codex.wordpress.org/Function_Reference/wp_insert_attachment) states that "The file MUST be on the uploads directory". I've added a line to move the uploaded file into the uploads directory and changed the guid path.
```
if( isset( $_POST['submit'] ) ) {
$filename = $_FILES['file']['na... |
136,283 | <p>I've created a custom post type named <code>mfg_ppn</code> and a custom taxonomy called <code>mfg_pp</code>, and they are referenced as <code>$this->cpt_promotion_news</code>and <code>$this->cpt_promotion</code>in case you were wondering about them.</p>
<p>Everything looks good in the admin, and I can easily ... | [
{
"answer_id": 136607,
"author": "Jonathan",
"author_id": 9591,
"author_profile": "https://wordpress.stackexchange.com/users/9591",
"pm_score": 4,
"selected": true,
"text": "<p>I don't know how or why, but this code below solved by issue. Seems to me like I shouldn't need it, but apparen... | 2014/02/28 | [
"https://wordpress.stackexchange.com/questions/136283",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9591/"
] | I've created a custom post type named `mfg_ppn` and a custom taxonomy called `mfg_pp`, and they are referenced as `$this->cpt_promotion_news`and `$this->cpt_promotion`in case you were wondering about them.
Everything looks good in the admin, and I can easily assign the taxonomy to the custom posts. But when I visit my... | I don't know how or why, but this code below solved by issue. Seems to me like I shouldn't need it, but apparently I do.
```
add_filter('pre_get_posts', array(&$this, 'modify_pre_query_request'));
public function modify_pre_query_request($query){
if ($query->is_main_query()){
if ($query->is_tax){
... |
136,287 | <p>Can I force a theme? I mean that the user cannot change intentionaly or accidentaly the theme I made for that website.
I would like to do this from the core because I also want to lock all updates.</p>
| [
{
"answer_id": 160435,
"author": "Bryan Willis",
"author_id": 38123,
"author_profile": "https://wordpress.stackexchange.com/users/38123",
"pm_score": 1,
"selected": false,
"text": "<p>Lot of useless comments on this post from what seems like a pretty simple question.</p>\n\n<p>change bel... | 2014/02/28 | [
"https://wordpress.stackexchange.com/questions/136287",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47554/"
] | Can I force a theme? I mean that the user cannot change intentionaly or accidentaly the theme I made for that website.
I would like to do this from the core because I also want to lock all updates. | Lot of useless comments on this post from what seems like a pretty simple question.
change below `$theme_directory_name = 'twentyfourteen';` to your theme... thats all you have to do. First function sets your theme no matter what. Second one disables interface to edit themes.
```
function selfish_hardcoded_theme() {
... |
136,306 | <p>I recently updated the permalink structure of a website from <code>/%postname%/</code> to <code>/%category%/%postname%/</code> this is obviously causing 404 errors. Instead of writing 301 redirects for each post is there any way to do this in a more automated fashion, within WordPress? I essentially want to programm... | [
{
"answer_id": 160435,
"author": "Bryan Willis",
"author_id": 38123,
"author_profile": "https://wordpress.stackexchange.com/users/38123",
"pm_score": 1,
"selected": false,
"text": "<p>Lot of useless comments on this post from what seems like a pretty simple question.</p>\n\n<p>change bel... | 2014/02/28 | [
"https://wordpress.stackexchange.com/questions/136306",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30778/"
] | I recently updated the permalink structure of a website from `/%postname%/` to `/%category%/%postname%/` this is obviously causing 404 errors. Instead of writing 301 redirects for each post is there any way to do this in a more automated fashion, within WordPress? I essentially want to programmatically 301 redirect the... | Lot of useless comments on this post from what seems like a pretty simple question.
change below `$theme_directory_name = 'twentyfourteen';` to your theme... thats all you have to do. First function sets your theme no matter what. Second one disables interface to edit themes.
```
function selfish_hardcoded_theme() {
... |
136,311 | <p>I add an image with caption to my page and need to increase <code><figure></code> width. But wordpress is adding an inline width.</p>
<pre><code>[caption id="attachment_44" align="alignnone" width="216"]<a href="image path"><img src="image path" alt="caption" width="216" height="95" class="size-full ... | [
{
"answer_id": 136313,
"author": "marcelo2605",
"author_id": 38553,
"author_profile": "https://wordpress.stackexchange.com/users/38553",
"pm_score": 3,
"selected": true,
"text": "<p><strong>SOLVED</strong></p>\n\n<p>I'm using roots theme. So I open cleanup.php file and comment/remove thi... | 2014/02/28 | [
"https://wordpress.stackexchange.com/questions/136311",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38553/"
] | I add an image with caption to my page and need to increase `<figure>` width. But wordpress is adding an inline width.
```
[caption id="attachment_44" align="alignnone" width="216"]<a href="image path"><img src="image path" alt="caption" width="216" height="95" class="size-full wp-image-44" /></a> caption [/caption]
... | **SOLVED**
I'm using roots theme. So I open cleanup.php file and comment/remove this line:
```
$attributes .= ' style="width: ' . (esc_attr($attr['width']) + 10) . 'px"';
``` |
136,320 | <p>In twenty fourteen theme, we’d like to know how to change the features content tag. Currently it’s set as <code>featured</code>.</p>
<p>Now, we would like to know how to code this for different page templates.</p>
<p>We notice in <code>page.php</code> there is a piece of code calling the template part <code>featur... | [
{
"answer_id": 136328,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 3,
"selected": false,
"text": "<p>The internal implementation details of that feature are of questionable sanity.</p>\n\n<ol>\n<li>If you take a look... | 2014/02/28 | [
"https://wordpress.stackexchange.com/questions/136320",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48075/"
] | In twenty fourteen theme, we’d like to know how to change the features content tag. Currently it’s set as `featured`.
Now, we would like to know how to code this for different page templates.
We notice in `page.php` there is a piece of code calling the template part `featured-content`.
```
<?php
if ( is_front_page()... | The internal implementation details of that feature are of questionable sanity.
1. If you take a look at said `featured-content.php` template you would see
2. that it get posts from `twentyfourteen_get_featured_posts()` however
3. the only thing that function has is `twentyfourteen_get_featured_posts` filter
4. from q... |
136,335 | <p>So I am trying to get a custom bulk action to work in Wordpress 3.7.1 and so far no luck. The basis I am using is <a href="http://www.skyverge.com/blog/add-custom-bulk-action" rel="nofollow">http://www.skyverge.com/blog/add-custom-bulk-action</a>, and it goes wrong here:</p>
<pre><code>$wp_list_table = _get_list_ta... | [
{
"answer_id": 136328,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 3,
"selected": false,
"text": "<p>The internal implementation details of that feature are of questionable sanity.</p>\n\n<ol>\n<li>If you take a look... | 2014/02/28 | [
"https://wordpress.stackexchange.com/questions/136335",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48322/"
] | So I am trying to get a custom bulk action to work in Wordpress 3.7.1 and so far no luck. The basis I am using is <http://www.skyverge.com/blog/add-custom-bulk-action>, and it goes wrong here:
```
$wp_list_table = _get_list_table('WP_Posts_List_Table');
$action = $wp_list_table->current_action();
```
The action itse... | The internal implementation details of that feature are of questionable sanity.
1. If you take a look at said `featured-content.php` template you would see
2. that it get posts from `twentyfourteen_get_featured_posts()` however
3. the only thing that function has is `twentyfourteen_get_featured_posts` filter
4. from q... |
136,387 | <p>I'm trying to figure out how to query for posts in my hierarchical custom post type, presumably using WP_Query that have child posts. I can get all pages that don't have children by setting <code>'post_parent' => 0</code> in my WP_Query args, but that returns all posts that are not children. I need only posts tha... | [
{
"answer_id": 136394,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 2,
"selected": false,
"text": "<p>You can use the <code>post_parent__not_in</code> parameter:</p>\n\n<pre><code>$args = array( \n 'po... | 2014/03/01 | [
"https://wordpress.stackexchange.com/questions/136387",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25300/"
] | I'm trying to figure out how to query for posts in my hierarchical custom post type, presumably using WP\_Query that have child posts. I can get all pages that don't have children by setting `'post_parent' => 0` in my WP\_Query args, but that returns all posts that are not children. I need only posts that have child po... | You can use the `post_parent__not_in` parameter:
```
$args = array(
'post_type' => 'cpt',
'post_parent__not_in' => array( 0 )
);
$query = new WP_Query( $args );
```
to retrieve *child* posts of type *cpt*.
The generated SQL will then include this part:
```
wp_posts.post_parent NOT... |
136,396 | <p>I want to Build a custom Page Template. But as far as I know we should not at all touch Core PHP files.</p>
<p>let say our Custom Page template is custom.php, then where will this custom.php sit I mean in which folder in wordpress or it will go some where in the inner directories of theme?</p>
<p>Because Finally w... | [
{
"answer_id": 136394,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 2,
"selected": false,
"text": "<p>You can use the <code>post_parent__not_in</code> parameter:</p>\n\n<pre><code>$args = array( \n 'po... | 2014/03/01 | [
"https://wordpress.stackexchange.com/questions/136396",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48182/"
] | I want to Build a custom Page Template. But as far as I know we should not at all touch Core PHP files.
let say our Custom Page template is custom.php, then where will this custom.php sit I mean in which folder in wordpress or it will go some where in the inner directories of theme?
Because Finally while creating a n... | You can use the `post_parent__not_in` parameter:
```
$args = array(
'post_type' => 'cpt',
'post_parent__not_in' => array( 0 )
);
$query = new WP_Query( $args );
```
to retrieve *child* posts of type *cpt*.
The generated SQL will then include this part:
```
wp_posts.post_parent NOT... |
136,397 | <p>Setting:</p>
<p>three open Tabs in browser:</p>
<p>Tab 1: Admin edit post</p>
<p>Tab 2: Frontend view of that post in "editing mode"</p>
<p>Tab 3: Frontend view in "non-editing" mode (default request)</p>
<p>I edit the post on Tab 2 (frontend editing) and save it via AJAX (via <code>wp_update_post</code>). When... | [
{
"answer_id": 136394,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 2,
"selected": false,
"text": "<p>You can use the <code>post_parent__not_in</code> parameter:</p>\n\n<pre><code>$args = array( \n 'po... | 2014/03/01 | [
"https://wordpress.stackexchange.com/questions/136397",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18247/"
] | Setting:
three open Tabs in browser:
Tab 1: Admin edit post
Tab 2: Frontend view of that post in "editing mode"
Tab 3: Frontend view in "non-editing" mode (default request)
I edit the post on Tab 2 (frontend editing) and save it via AJAX (via `wp_update_post`). When I refresh this Tab, or Tab 3, I can see the chan... | You can use the `post_parent__not_in` parameter:
```
$args = array(
'post_type' => 'cpt',
'post_parent__not_in' => array( 0 )
);
$query = new WP_Query( $args );
```
to retrieve *child* posts of type *cpt*.
The generated SQL will then include this part:
```
wp_posts.post_parent NOT... |
136,407 | <p>I have tried to upload it simply through the media library ,but it didnt display correctly (very low resolution) and some users couldnt even see it (just an empty space) ,so I used an iframe tag in a page and uploaded the pdf directly to the server.</p>
<pre><code><iframe frameborder="1" height="200" name="frame... | [
{
"answer_id": 136436,
"author": "DerLola",
"author_id": 37080,
"author_profile": "https://wordpress.stackexchange.com/users/37080",
"pm_score": 1,
"selected": false,
"text": "<p>If you're using Apache, you can add something like this in your .htaccess file</p>\n\n<p><code>AddType applic... | 2014/03/01 | [
"https://wordpress.stackexchange.com/questions/136407",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44632/"
] | I have tried to upload it simply through the media library ,but it didnt display correctly (very low resolution) and some users couldnt even see it (just an empty space) ,so I used an iframe tag in a page and uploaded the pdf directly to the server.
```
<iframe frameborder="1" height="200" name="frame1" scrolling="yes... | If you're using Apache, you can add something like this in your .htaccess file
`AddType application/octet-stream .pdf`
This will force everything with a .pdf extension to download instead of display in the browser.
If however you are not using Apache or if you want only certain files to download and others to displa... |
136,432 | <p>I have PHP script outside the WordPress directory where I'm getting the content of a specific post and now trying to apply the <code>oembed</code> filter on it:</p>
<pre><code>include('../wp-load.php');
$thePost = get_post(42, ARRAY_A);
$theContent = $thePost['post_content'];
</code></pre>
<p>The post's content co... | [
{
"answer_id": 136433,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>\"autoembedding\", at least last I checked, operates due to a filter on <code>the_content</code>. Your code ... | 2014/03/01 | [
"https://wordpress.stackexchange.com/questions/136432",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48358/"
] | I have PHP script outside the WordPress directory where I'm getting the content of a specific post and now trying to apply the `oembed` filter on it:
```
include('../wp-load.php');
$thePost = get_post(42, ARRAY_A);
$theContent = $thePost['post_content'];
```
The post's content contains text and one or more URLs to Y... | You need to set the global `$post` object to your post. This is done by the loop functions in your theme which is why it works there.
WP's oEmbed replaces the URLs during the `the_content` filter. But it replaces the URLs through two means. The first is a simple regex find and replace for certain URLs such as Google V... |
136,441 | <p>I have the "video" shortcode and the "tabs" shortcode.</p>
<pre><code>[video]code youtube[/video]
[tabs]
[tab title="text"][/tab]
[tab title="text"][/tab]
[/tabs]
</code></pre>
<p>If I write the video shortcode into a tab, the "video" shortcode doesn't work...
How can I resolve?</p>
| [
{
"answer_id": 136433,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>\"autoembedding\", at least last I checked, operates due to a filter on <code>the_content</code>. Your code ... | 2014/03/01 | [
"https://wordpress.stackexchange.com/questions/136441",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/41537/"
] | I have the "video" shortcode and the "tabs" shortcode.
```
[video]code youtube[/video]
[tabs]
[tab title="text"][/tab]
[tab title="text"][/tab]
[/tabs]
```
If I write the video shortcode into a tab, the "video" shortcode doesn't work...
How can I resolve? | You need to set the global `$post` object to your post. This is done by the loop functions in your theme which is why it works there.
WP's oEmbed replaces the URLs during the `the_content` filter. But it replaces the URLs through two means. The first is a simple regex find and replace for certain URLs such as Google V... |
136,458 | <p>I have a custom post type 'news' and a taxonomy 'category-news'.
I would like to get this permalinks:</p>
<pre><code> www.domain.com/news -------------> list of all news
www.domain.com/news/sport -------> list of all sport news
www.domain.com/news/sport/post --> the post
www.domain.com/news/... | [
{
"answer_id": 136433,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>\"autoembedding\", at least last I checked, operates due to a filter on <code>the_content</code>. Your code ... | 2014/03/01 | [
"https://wordpress.stackexchange.com/questions/136458",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16871/"
] | I have a custom post type 'news' and a taxonomy 'category-news'.
I would like to get this permalinks:
```
www.domain.com/news -------------> list of all news
www.domain.com/news/sport -------> list of all sport news
www.domain.com/news/sport/post --> the post
www.domain.com/news/2014 --------> list of ... | You need to set the global `$post` object to your post. This is done by the loop functions in your theme which is why it works there.
WP's oEmbed replaces the URLs during the `the_content` filter. But it replaces the URLs through two means. The first is a simple regex find and replace for certain URLs such as Google V... |
136,486 | <p>I have a post category structure like this:</p>
<ul>
<li>news</li>
<li>news / conferences</li>
<li>news / newsletter</li>
</ul>
<p>In Appearance > Menu, I have added 3 menu items.</p>
<p>One each for the categories News, Conferences, Newsletter.</p>
<p>However, the News page also displays posts from Conferences ... | [
{
"answer_id": 136490,
"author": "1fixdotio",
"author_id": 45728,
"author_profile": "https://wordpress.stackexchange.com/users/45728",
"pm_score": 2,
"selected": false,
"text": "<p>I rewrote the code from <a href=\"http://wpengineer.com/876/exclude-subcategories-in-a-loop/\" rel=\"nofoll... | 2014/03/02 | [
"https://wordpress.stackexchange.com/questions/136486",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3206/"
] | I have a post category structure like this:
* news
* news / conferences
* news / newsletter
In Appearance > Menu, I have added 3 menu items.
One each for the categories News, Conferences, Newsletter.
However, the News page also displays posts from Conferences and Newsletter.
How do I exclude posts from subcategori... | I rewrote the code from [a post at WP Engineer](http://wpengineer.com/876/exclude-subcategories-in-a-loop/):
```
function wpse_filter_child_cats( $query ) {
if ( $query->is_category ) {
$queried_object = get_queried_object();
$child_cats = (array) get_term_children( $queried_object->term_id, 'category' );
... |
136,524 | <p>With raw SQL through <code>$wpdb</code>, I believe that I could do something along the lines of this (untested):</p>
<pre><code>SELECT post_id, meta_value
FROM postmeta
WHERE meta_key = '_wp_attachment_metadata'
AND meta_value LIKE '%:"custom_key";a:%'
</code></pre>
<p>That said, if there is built-in functionality... | [
{
"answer_id": 136527,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 0,
"selected": false,
"text": "<p>You can do this with <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query\" rel=\"nofollow... | 2014/03/02 | [
"https://wordpress.stackexchange.com/questions/136524",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15299/"
] | With raw SQL through `$wpdb`, I believe that I could do something along the lines of this (untested):
```
SELECT post_id, meta_value
FROM postmeta
WHERE meta_key = '_wp_attachment_metadata'
AND meta_value LIKE '%:"custom_key";a:%'
```
That said, if there is built-in functionality for this kind of query then I would ... | While you can do this with `WP_Query`, I'd do this the way you are trying to avoid-- save a list in a separate key. The "pros" strongly outweigh the "cons" in my mind.
1. `LIKE` queries with wildcards, especially with leading wildcards,
are not efficient-- aka, "slow"
2. and a `LIKE` query on serialized data is going ... |
136,539 | <p>I'm currently developing a WordPress theme where I want the user to be able to upload images before he register or log in to the site.</p>
<p>The initial problem was, you can't upload images to WordPress using the <code>wp.media</code> JavaScript class if you are not a registered user.</p>
<p>The solution I create... | [
{
"answer_id": 136527,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 0,
"selected": false,
"text": "<p>You can do this with <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query\" rel=\"nofollow... | 2014/03/03 | [
"https://wordpress.stackexchange.com/questions/136539",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48404/"
] | I'm currently developing a WordPress theme where I want the user to be able to upload images before he register or log in to the site.
The initial problem was, you can't upload images to WordPress using the `wp.media` JavaScript class if you are not a registered user.
The solution I create is actually very simple:
1... | While you can do this with `WP_Query`, I'd do this the way you are trying to avoid-- save a list in a separate key. The "pros" strongly outweigh the "cons" in my mind.
1. `LIKE` queries with wildcards, especially with leading wildcards,
are not efficient-- aka, "slow"
2. and a `LIKE` query on serialized data is going ... |
136,587 | <p>I picked up someone's old project at the company I work at. They created a plugin to add courses to the website (including dates, location etc), but they didn't add the possibility to select a category for the course.</p>
<p>I want to add this function, which I tried by looking at their other code and copy/pasting ... | [
{
"answer_id": 136592,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": false,
"text": "<p>When your taxonomy is already registered (or is a built-in one like post tags, categories, etc.), you can simply g... | 2014/03/03 | [
"https://wordpress.stackexchange.com/questions/136587",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48421/"
] | I picked up someone's old project at the company I work at. They created a plugin to add courses to the website (including dates, location etc), but they didn't add the possibility to select a category for the course.
I want to add this function, which I tried by looking at their other code and copy/pasting it and ada... | Alternatively to Kaiser's answer, when you register the post type, simply use the `taxonomies` attribute:
```
register_post_type( 'my-cpt', array(
...
'taxonomies' => array( 'category' ),
...
) );
```
Details on `register_post_type()` can be [found here in Codex](http://codex.wordpress.org/Function_Reference/r... |
136,613 | <p>So after I have created the table 'settings-table' i want to add a couple of records to it.</p>
<p>This is how I want to do it, not the best way, so I need a better way to do this because I will add more records to the table.</p>
<p>EXAMPLE 1</p>
<pre><code> $wpdb->insert('settings-table', array('option_name' ... | [
{
"answer_id": 151687,
"author": "rajesh",
"author_id": 54704,
"author_profile": "https://wordpress.stackexchange.com/users/54704",
"pm_score": 3,
"selected": false,
"text": "<pre><code>$wpdb->query(\"INSERT INTO settings-table\n (option_name, option_value, option_created, ... | 2014/03/03 | [
"https://wordpress.stackexchange.com/questions/136613",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47687/"
] | So after I have created the table 'settings-table' i want to add a couple of records to it.
This is how I want to do it, not the best way, so I need a better way to do this because I will add more records to the table.
EXAMPLE 1
```
$wpdb->insert('settings-table', array('option_name' => 'name-1',
... | ```
$wpdb->query("INSERT INTO settings-table
(option_name, option_value, option_created, option_edit, option_user)
VALUES
('name-1', 'val-1', current_time('mysql'), current_time('mysql'), 'user-1'),
('name-2', 'val-2', current_time('mysql'), current_time('mysql'), 'user-2... |
136,616 | <p>I solved the problem of displaying from a custom post type in a post with <a href="https://stackoverflow.com/questions/18762065/displaying-custom-post-type-on-page">this solution</a>, however, I want to filter even more and only display the posts from custom post type that match the main post's category (or to be mo... | [
{
"answer_id": 136617,
"author": "Rvervuurt",
"author_id": 48421,
"author_profile": "https://wordpress.stackexchange.com/users/48421",
"pm_score": 0,
"selected": false,
"text": "<p>Okay, it was more simple than expected.</p>\n\n<pre><code><?php if ($cat_slug_course == $cat_slug): ?>... | 2014/03/03 | [
"https://wordpress.stackexchange.com/questions/136616",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48421/"
] | I solved the problem of displaying from a custom post type in a post with [this solution](https://stackoverflow.com/questions/18762065/displaying-custom-post-type-on-page), however, I want to filter even more and only display the posts from custom post type that match the main post's category (or to be more precise the... | A better solution than the one you found on your own, would be to only retrieve matching posts in the first place. As is, you are potentially retrieving the wrong data. With your code (your solution), what happens if the two posts in the result set *don't* match? You get no output at all.
Your description/code is a bi... |
136,624 | <p>My Wordpress site has fairly long entries and includes many data visualisations. I want to make it easier for visitors to refer to a specific part of a page and therefore would like to make it easy to link to a specific headline.</p>
<p>I would like to make it possible for the visitors to link to the 'id' of a head... | [
{
"answer_id": 136639,
"author": "Mayeenul Islam",
"author_id": 22728,
"author_profile": "https://wordpress.stackexchange.com/users/22728",
"pm_score": 0,
"selected": false,
"text": "<p>Linking to a subheading is called Bookmarking. It can be done using a simple anchor tag, but no actual... | 2014/03/03 | [
"https://wordpress.stackexchange.com/questions/136624",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47229/"
] | My Wordpress site has fairly long entries and includes many data visualisations. I want to make it easier for visitors to refer to a specific part of a page and therefore would like to make it easy to link to a specific headline.
I would like to make it possible for the visitors to link to the 'id' of a headline. I th... | Analysed situation
------------------
When you take a look at your (original) example "GitHub" and it's source code, you see the following:
```
<a name="updating-submodules" class="anchor" href="#updating-submodules">
<span class="octicon octicon-link"></span>
</a>
```
Prerequisites
-------------
Basically thi... |
136,627 | <p>I'm trying to select the <code>post_title</code> from <code>wp_posts</code> with a query which I did using this method:</p>
<pre><code> global $wpdb;
$test = $wpdb->get_var(
$wpdb->prepare(" SELECT post_title FROM {$wpdb->wp_posts}" )
);
echo "$test";
</code></pre>
<p>EDIT: It ... | [
{
"answer_id": 136642,
"author": "Douglas Radburn",
"author_id": 48142,
"author_profile": "https://wordpress.stackexchange.com/users/48142",
"pm_score": 0,
"selected": false,
"text": "<p>You should be able to get the <code>posts</code> table name using.</p>\n\n<pre><code>$tableName = $wp... | 2014/03/03 | [
"https://wordpress.stackexchange.com/questions/136627",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48416/"
] | I'm trying to select the `post_title` from `wp_posts` with a query which I did using this method:
```
global $wpdb;
$test = $wpdb->get_var(
$wpdb->prepare(" SELECT post_title FROM {$wpdb->wp_posts}" )
);
echo "$test";
```
EDIT: It now gives me:
```
Notice: Undefined property: wpdb::$wp_... | First, it's not `$wpdb->wp_posts`, it's just `$wpdb->posts`.
Second, you're using prepare() incorrectly. You use prepare when you have some variable data that you need to safely insert into the query string, not otherwise. Using prepare on a known string does nothing and throws a warning.
For example:
```
$data = 'e... |
136,636 | <p>I have installed my wordpress in root/mysubfolder
so my standard path is example1.com/mysubfolder (example1.com is the domain i have registered the webspace with)</p>
<p>Now i want the wordpress installation to work with example2.com (registered another domain)
Therefore i have set the redirect for example2.com to ... | [
{
"answer_id": 136642,
"author": "Douglas Radburn",
"author_id": 48142,
"author_profile": "https://wordpress.stackexchange.com/users/48142",
"pm_score": 0,
"selected": false,
"text": "<p>You should be able to get the <code>posts</code> table name using.</p>\n\n<pre><code>$tableName = $wp... | 2014/03/03 | [
"https://wordpress.stackexchange.com/questions/136636",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43061/"
] | I have installed my wordpress in root/mysubfolder
so my standard path is example1.com/mysubfolder (example1.com is the domain i have registered the webspace with)
Now i want the wordpress installation to work with example2.com (registered another domain)
Therefore i have set the redirect for example2.com to the folder... | First, it's not `$wpdb->wp_posts`, it's just `$wpdb->posts`.
Second, you're using prepare() incorrectly. You use prepare when you have some variable data that you need to safely insert into the query string, not otherwise. Using prepare on a known string does nothing and throws a warning.
For example:
```
$data = 'e... |
136,655 | <p>I'm making a navigation plugin which adds animations to your wordpress navigation.</p>
<p>I read in Wordpress Codex that I would need to use wp_enqueue_style().</p>
<p>First, How do I use this code for multiple css files?
in my main plugin file.</p>
<p>Now according to <a href="https://wordpress.stackexchange.com... | [
{
"answer_id": 136658,
"author": "ScottMcGready",
"author_id": 48444,
"author_profile": "https://wordpress.stackexchange.com/users/48444",
"pm_score": 0,
"selected": false,
"text": "<p>Use an if to check if it conforms to your criteria, for example</p>\n\n<ol>\n<li>a specific page/post (... | 2014/03/03 | [
"https://wordpress.stackexchange.com/questions/136655",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48443/"
] | I'm making a navigation plugin which adds animations to your wordpress navigation.
I read in Wordpress Codex that I would need to use wp\_enqueue\_style().
First, How do I use this code for multiple css files?
in my main plugin file.
Now according to [this](https://wordpress.stackexchange.com/questions/27604/wp-enqu... | To answer your first question, you would use the second style, i.e.
```
function add_my_stylesheet()
{
wp_enqueue_style( 'myCSS', plugins_url( '/css/myCSS.css', __FILE__ ) );
wp_enqueue_style( 'myCSS1', plugins_url( '/css/myCSS1.css', __FILE__ ) );
}
add_action('admin_print_styles', 'add_my_stylesheet');
``... |
136,662 | <p>I have a simple 4 item menu on wordpress. I want to use the bootstrap button style for this menu.</p>
<p>This is the hand-made code of what I want to get.</p>
<pre><code><div class="menu-menu-container">
<ul id="menu-menu" class="btn-group">
<li id="menu-item-16" class="btn btn-default"><a hre... | [
{
"answer_id": 136684,
"author": "Galen Gidman",
"author_id": 11549,
"author_profile": "https://wordpress.stackexchange.com/users/11549",
"pm_score": 0,
"selected": false,
"text": "<p>I don't think there's an easy way to add classes the list items themselves, but it would be easy to wrap... | 2014/03/03 | [
"https://wordpress.stackexchange.com/questions/136662",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9477/"
] | I have a simple 4 item menu on wordpress. I want to use the bootstrap button style for this menu.
This is the hand-made code of what I want to get.
```
<div class="menu-menu-container">
<ul id="menu-menu" class="btn-group">
<li id="menu-item-16" class="btn btn-default"><a href="http://localhost/test/?page_id=5">Link ... | The following should setup your menu with the correct classes and IDs applied to your container and ul. The codex entry for [wp\_nav\_menu](http://codex.wordpress.org/Function_Reference/wp_nav_menu) lists all the possible arguments.
```
wp_nav_menu( array(
'theme_location' => 'primary',
'container_class' => ... |
136,678 | <p>I have the following problem developing a WordPress theme and I am here to ask you if this solution could be a good solution or if exist some better way to do.</p>
<p>I have a custom WP theme and into this theme there is a main menu. The website is multilanguage (italian and english) so I have to load the Italian m... | [
{
"answer_id": 137678,
"author": "Nicolae",
"author_id": 47232,
"author_profile": "https://wordpress.stackexchange.com/users/47232",
"pm_score": 1,
"selected": false,
"text": "<p>I had the same problem. I used Polylang plugin and 3 languages. So i created 3 menus like this: <a href=\"htt... | 2014/03/03 | [
"https://wordpress.stackexchange.com/questions/136678",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29275/"
] | I have the following problem developing a WordPress theme and I am here to ask you if this solution could be a good solution or if exist some better way to do.
I have a custom WP theme and into this theme there is a main menu. The website is multilanguage (italian and english) so I have to load the Italian main menu (... | I had the same problem. I used Polylang plugin and 3 languages. So i created 3 menus like this: <https://www.diigo.com/item/image/4o9rz/opx5>.
after that i checked the language and displayed the correct menu,like this:
```
<?php
if (get_locale() == 'en_US') {
wp_nav_menu(array(
... |
136,708 | <p>How do i grab data from a post and insert it into the form, So when the form is sent it will have that post name and image from that page that the form was sent on? </p>
<p>Basicly I have a get a quote button and i want them to click that and ask about the product by inputting field by contact form 7, but I want... | [
{
"answer_id": 138749,
"author": "hawbsl",
"author_id": 875,
"author_profile": "https://wordpress.stackexchange.com/users/875",
"pm_score": 0,
"selected": false,
"text": "<p>I think you can do this, or at least the text part (not sure about the image) using the plugin <strong>Contact For... | 2014/03/04 | [
"https://wordpress.stackexchange.com/questions/136708",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48400/"
] | How do i grab data from a post and insert it into the form, So when the form is sent it will have that post name and image from that page that the form was sent on?
Basicly I have a get a quote button and i want them to click that and ask about the product by inputting field by contact form 7, but I want the name of ... | Contact Form 7 has built in [Special Mail Tags](http://contactform7.com/special-mail-tags/):
```
[_post_id]
[_post_title]
```
If you can insert the Contact Form into "The Loop", Contact Form 7 will automatically pull this information. If it is indeed in the loop, you can use [Contact Form 7 - Before Send Mail Hook](... |
136,714 | <p>I have a small problem with <code>WP_Query</code>. I want to get the posts filtered by category and with similar project name (like query), so I'm trying this code:</p>
<pre><code>$args=array(
'post_type' => 'post',
'post_status' => 'publish',
'category_name' => 'projects',
'name__like' => 'Proj');
$my... | [
{
"answer_id": 136758,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 4,
"selected": false,
"text": "<p><em>Revisited and simplified answer:</em></p>\n\n<p>You can try:</p>\n\n<pre><code>$args = [\n 'post_type'... | 2014/03/04 | [
"https://wordpress.stackexchange.com/questions/136714",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43759/"
] | I have a small problem with `WP_Query`. I want to get the posts filtered by category and with similar project name (like query), so I'm trying this code:
```
$args=array(
'post_type' => 'post',
'post_status' => 'publish',
'category_name' => 'projects',
'name__like' => 'Proj');
$my_query = null;
$my_query = new WP_Que... | I did not use any `name__like` or filters. This is how I finally made it:
```
$categoria = $_GET['categoria'];
$filtro = $_GET['texto'];
$args = array(
'post_type' => 'post',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'category',
'field' => 'slug',
... |
136,725 | <p>I've got the following code, which changes the page template if 'street-style' is picked from the categories.</p>
<p>However, I'd like to change this to the tag 'street'. I currently have:</p>
<pre><code>function get_custom_cat_template($single_template) {
global $post;
if ( in_category( 'street-style... | [
{
"answer_id": 136727,
"author": "fischi",
"author_id": 15680,
"author_profile": "https://wordpress.stackexchange.com/users/15680",
"pm_score": 2,
"selected": false,
"text": "<p>The function <code>is_tag()</code> is used to determine if a tag archive page is displayed, not if a post has ... | 2014/03/04 | [
"https://wordpress.stackexchange.com/questions/136725",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33541/"
] | I've got the following code, which changes the page template if 'street-style' is picked from the categories.
However, I'd like to change this to the tag 'street'. I currently have:
```
function get_custom_cat_template($single_template) {
global $post;
if ( in_category( 'street-style' )) {
$sin... | I think the function you are looking for is [`has_tag()`](https://codex.wordpress.org/Function_Reference/has_tag) or even more generically [`has_term()`](https://codex.wordpress.org/Function_Reference/has_term).
Your function would then become:
```
function get_custom_cat_template($single_template) {
global $pos... |
136,738 | <p>Our visual editor is displaying raw HTML:
<img src="https://i.stack.imgur.com/qWkN8.png" alt="enter image description here"></p>
<p>If I click on Visual or Text, nothing happens at all - the click isn't registering.</p>
<p>My profile does not have "disable visual editor" checked.</p>
<p>The same thing happens in ... | [
{
"answer_id": 152462,
"author": "sri",
"author_id": 34200,
"author_profile": "https://wordpress.stackexchange.com/users/34200",
"pm_score": 0,
"selected": false,
"text": "<p>There is an interesting post <a href=\"http://wordpress.org/support/topic/htmlvisual-missing-on-341-and-342#post-... | 2014/03/04 | [
"https://wordpress.stackexchange.com/questions/136738",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3206/"
] | Our visual editor is displaying raw HTML:

If I click on Visual or Text, nothing happens at all - the click isn't registering.
My profile does not have "disable visual editor" checked.
The same thing happens in Chrome, Opera & Firefox.
I have disab... | This almost certainly happens because WordPress cannot load the TinyMCE editor files or the TinyMCE javascript code could not be run.
Try these things:
---
1) Make sure your browser has javascript enabled!
---
2) Open this URL in your browser `http://<yoursite>/wp-includes/js/tinymce/wp-tinymce.php`
You should see ... |
136,762 | <p>I made a few custom taxonomies and I need to show ALL the terms from it, what I achieved so far is showing the taxonomies that are selected/chosen in a custom post type but I need all of them to show, wether it's selected or not.
So that later I can make a filter that filters according to which terms a custom post t... | [
{
"answer_id": 136766,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 7,
"selected": true,
"text": "<p>You need to pass an additional argument to <a href=\"http://codex.wordpress.org/Function_Reference/get_terms\... | 2014/03/04 | [
"https://wordpress.stackexchange.com/questions/136762",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48416/"
] | I made a few custom taxonomies and I need to show ALL the terms from it, what I achieved so far is showing the taxonomies that are selected/chosen in a custom post type but I need all of them to show, wether it's selected or not.
So that later I can make a filter that filters according to which terms a custom post type... | You need to pass an additional argument to [`get_terms()`](http://codex.wordpress.org/Function_Reference/get_terms). The default is to hide "empty" terms-- terms which are assigned to no posts.
```
$terms = get_terms([
'taxonomy' => $taxonomy,
'hide_empty' => false,
]);
```
**EDIT**:
Incase you want to disp... |
136,767 | <p>I'm working with a client who is wrapping the body of our WordPress site with their own external header and footer, stripping out our header and footer. Our enqueued plugin scripts then, aren't working because our header and footer aren't used at all. Also, it seems to me that NO plugins would work if they're not us... | [
{
"answer_id": 136766,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 7,
"selected": true,
"text": "<p>You need to pass an additional argument to <a href=\"http://codex.wordpress.org/Function_Reference/get_terms\... | 2014/03/04 | [
"https://wordpress.stackexchange.com/questions/136767",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8822/"
] | I'm working with a client who is wrapping the body of our WordPress site with their own external header and footer, stripping out our header and footer. Our enqueued plugin scripts then, aren't working because our header and footer aren't used at all. Also, it seems to me that NO plugins would work if they're not using... | You need to pass an additional argument to [`get_terms()`](http://codex.wordpress.org/Function_Reference/get_terms). The default is to hide "empty" terms-- terms which are assigned to no posts.
```
$terms = get_terms([
'taxonomy' => $taxonomy,
'hide_empty' => false,
]);
```
**EDIT**:
Incase you want to disp... |
136,771 | <p>I have this url:</p>
<pre><code>http://sitename.com/?game=runescape
</code></pre>
<p>Is it possible to modify the htaccess file or rewrite the url via Wordpress to become like this:</p>
<pre><code>http://sitename.com/game/runescape
</code></pre>
| [
{
"answer_id": 136772,
"author": "fischi",
"author_id": 15680,
"author_profile": "https://wordpress.stackexchange.com/users/15680",
"pm_score": 0,
"selected": false,
"text": "<p>Just go to \"Settings\"=>\"Permalinks\" and check the option \"Post Name\".</p>\n\n<p>WordPress handles the re... | 2014/03/04 | [
"https://wordpress.stackexchange.com/questions/136771",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48487/"
] | I have this url:
```
http://sitename.com/?game=runescape
```
Is it possible to modify the htaccess file or rewrite the url via Wordpress to become like this:
```
http://sitename.com/game/runescape
``` | First, add a WordPress page named `game` to direct requests to.
Next, add the `game` query var so WordPress knows what it is:
```
add_filter( 'query_vars', 'wpa_query_vars' );
function wpa_query_vars( $query_vars ){
$query_vars[] = 'game';
return $query_vars;
}
```
Then, add a rewrite rule to handle the inc... |
136,774 | <p>I'm just completely mixed-up with this.
I need the 1st post of the loop looks differently,
as a kind of magazine style, you know: bigger thumbnail
and bigger title.</p>
<p>I tried already nth-of-type in CSS, :first-child, and
different php variations.
But nothing works.</p>
<p>Here is the main part of code on inde... | [
{
"answer_id": 136811,
"author": "Morgan Estes",
"author_id": 26317,
"author_profile": "https://wordpress.stackexchange.com/users/26317",
"pm_score": 0,
"selected": false,
"text": "<p>Since you're using the default loop (not a custom one), you can check the counter for the first (0th) lo... | 2014/03/04 | [
"https://wordpress.stackexchange.com/questions/136774",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48489/"
] | I'm just completely mixed-up with this.
I need the 1st post of the loop looks differently,
as a kind of magazine style, you know: bigger thumbnail
and bigger title.
I tried already nth-of-type in CSS, :first-child, and
different php variations.
But nothing works.
Here is the main part of code on index.php::
```
<h3 ... | Since you're using the default loop (not a custom one), you can check the counter for the first (0th) loop and alter your output just for that one.
The WordPress support forum had [a similar question](http://wordpress.org/support/topic/target-first-post-in-loop#post-3234154) that offered this bit of code:
```
if( $wp... |
136,784 | <p>I'm using this example as a guide <a href="http://pippinsplugins.com/process-ajax-requests-correctly-in-wordpress-plugins/" rel="nofollow">link to ajax example i'm using</a> to my plugin example. I get <code>Uncaught ReferenceError: the_ajax_script is not defined</code> in the JS console .</p>
<p>I've put my JS in ... | [
{
"answer_id": 136787,
"author": "Jonathan",
"author_id": 48491,
"author_profile": "https://wordpress.stackexchange.com/users/48491",
"pm_score": 2,
"selected": true,
"text": "<p>Until ajaxurl is always defined as of WP 2.8 you can simply remove the_ajax_script from here <code>$.post(the... | 2014/03/04 | [
"https://wordpress.stackexchange.com/questions/136784",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I'm using this example as a guide [link to ajax example i'm using](http://pippinsplugins.com/process-ajax-requests-correctly-in-wordpress-plugins/) to my plugin example. I get `Uncaught ReferenceError: the_ajax_script is not defined` in the JS console .
I've put my JS in the main php file. The PHP that processes a res... | Until ajaxurl is always defined as of WP 2.8 you can simply remove the\_ajax\_script from here `$.post(the_ajax_script.ajaxurl`.
You create the object the\_ajax\_script for the activate2 script but don't but the code that uses this object in that file. |
136,790 | <p>I am new with WordPress development and I have found this query and I want pass multiple key and value in this query.</p>
<p>My Query is:</p>
<pre><code>$querydetails = "
SELECT wposts.*
FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
WHERE wposts.ID = wpostmeta.post_id
AND wpostmeta.met... | [
{
"answer_id": 136791,
"author": "Jonathan",
"author_id": 48491,
"author_profile": "https://wordpress.stackexchange.com/users/48491",
"pm_score": -1,
"selected": false,
"text": "<pre><code>// The Query\n$the_query = new WP_Query( $args );\n\n// The Loop\nif ( $the_query->have_posts() ... | 2014/03/04 | [
"https://wordpress.stackexchange.com/questions/136790",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26204/"
] | I am new with WordPress development and I have found this query and I want pass multiple key and value in this query.
My Query is:
```
$querydetails = "
SELECT wposts.*
FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
WHERE wposts.ID = wpostmeta.post_id
AND wpostmeta.meta_key = 'type' AND wpostmet... | Try this:
```
<?php
$querydetails = "
SELECT wposts.*
FROM $wpdb->posts wposts
INNER
JOIN ( SELECT post_id
FROM $wpdb->postmeta wpostmeta
WHERE (
( wpostmeta.meta_key = 'type' AND wpostmeta.meta... |
136,796 | <p>On my primary navigation, I want each top level page to have a list of the subpages. So I created code that dynamically adds menu items to the primary navigation. This works only on the first level of subpages. You can see that I commented out the code that goes down to the second level because it output those links... | [
{
"answer_id": 136791,
"author": "Jonathan",
"author_id": 48491,
"author_profile": "https://wordpress.stackexchange.com/users/48491",
"pm_score": -1,
"selected": false,
"text": "<pre><code>// The Query\n$the_query = new WP_Query( $args );\n\n// The Loop\nif ( $the_query->have_posts() ... | 2014/03/04 | [
"https://wordpress.stackexchange.com/questions/136796",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45698/"
] | On my primary navigation, I want each top level page to have a list of the subpages. So I created code that dynamically adds menu items to the primary navigation. This works only on the first level of subpages. You can see that I commented out the code that goes down to the second level because it output those links on... | Try this:
```
<?php
$querydetails = "
SELECT wposts.*
FROM $wpdb->posts wposts
INNER
JOIN ( SELECT post_id
FROM $wpdb->postmeta wpostmeta
WHERE (
( wpostmeta.meta_key = 'type' AND wpostmeta.meta... |
136,798 | <p>I've got a simple loop, that goes through the category <code>street-style</code>:</p>
<pre><code>$street_style_tags = array(
'category_name' => 'street-style',
'posts_per_page' => 25,
'post_type' => 'post',
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC'
);
</code></pre>
<... | [
{
"answer_id": 136806,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>If you want to globally exclude a category add a filter on <code>pre_get_posts</code>.</p>\n\n<pre><code>fun... | 2014/03/04 | [
"https://wordpress.stackexchange.com/questions/136798",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33541/"
] | I've got a simple loop, that goes through the category `street-style`:
```
$street_style_tags = array(
'category_name' => 'street-style',
'posts_per_page' => 25,
'post_type' => 'post',
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC'
);
```
However, it is coming up in loops elsewhere on the si... | This is pretty easy. WP\_Query has different argument you can use to exclude a category. The (little) problematic part is how to exclude that category from all loops, being able to still directly querying it.
You can use `'pre_get_post'` action hook, check the `'category_name'` argument of current query and if it's di... |
136,803 | <p>I have a custom post type I am generating in functions.php. I would like each post to be a page, rather than a post. How can I change this? I tried changing 'capability_type' => 'post' to 'capability_type' => 'page' - but this did not work.</p>
<pre><code>// LFIO: Custom post type: Case Results
add_action( 'init', ... | [
{
"answer_id": 136812,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 0,
"selected": false,
"text": "<blockquote>\n <p>I'm hoping that this specific custom post type will use my normal page\n template, rather ... | 2014/03/04 | [
"https://wordpress.stackexchange.com/questions/136803",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5205/"
] | I have a custom post type I am generating in functions.php. I would like each post to be a page, rather than a post. How can I change this? I tried changing 'capability\_type' => 'post' to 'capability\_type' => 'page' - but this did not work.
```
// LFIO: Custom post type: Case Results
add_action( 'init', 'register_cp... | Another easy method is for this to be the entirety of your `single-result.php`.
```
<?php
get_template_part( 'page' );
```
This will literally use your `page.php` file, no need to duplicate the content. That way, you won't need to make changes in 2 locations. |
136,805 | <p>I need to filter the Posts and Pages tables in the Admin panel by certain shortcodes. In my plugin, I have added a column for shortcodes to the Posts and Pages views that works like the "Categories" and "Tags" columns, displaying a listing of shortcodes that are used in each post. Now I want to be able to click on o... | [
{
"answer_id": 136812,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 0,
"selected": false,
"text": "<blockquote>\n <p>I'm hoping that this specific custom post type will use my normal page\n template, rather ... | 2014/03/04 | [
"https://wordpress.stackexchange.com/questions/136805",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47975/"
] | I need to filter the Posts and Pages tables in the Admin panel by certain shortcodes. In my plugin, I have added a column for shortcodes to the Posts and Pages views that works like the "Categories" and "Tags" columns, displaying a listing of shortcodes that are used in each post. Now I want to be able to click on one ... | Another easy method is for this to be the entirety of your `single-result.php`.
```
<?php
get_template_part( 'page' );
```
This will literally use your `page.php` file, no need to duplicate the content. That way, you won't need to make changes in 2 locations. |
136,813 | <p>Im looking at how to breakdown the output from <strong>wp_list_categories</strong>. Currently it shows:</p>
<pre><code><a href="http://www.oddpandadesign.co.uk/shaun/cat-band/drummer/" title="View all posts filed under Drummer">Drummer</a>
</code></pre>
<p>But I am looking to only get the category name... | [
{
"answer_id": 136818,
"author": "Pranay Bhardwaj",
"author_id": 48500,
"author_profile": "https://wordpress.stackexchange.com/users/48500",
"pm_score": 0,
"selected": false,
"text": "<p>You can try:</p>\n\n<pre><code><?php\n $category_ids = get_all_category_ids();\n foreach($catego... | 2014/03/04 | [
"https://wordpress.stackexchange.com/questions/136813",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45403/"
] | Im looking at how to breakdown the output from **wp\_list\_categories**. Currently it shows:
```
<a href="http://www.oddpandadesign.co.uk/shaun/cat-band/drummer/" title="View all posts filed under Drummer">Drummer</a>
```
But I am looking to only get the category name without the link. So would be `Drummer`.
My ful... | A custom category walker should do what you need.
```
class My_Cat_Walker extends Walker_Category {
function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
extract($args);
$cat_name = esc_attr( $category->name );
$cat_name = apply_filters( 'list_cats', $cat_name, $category );
... |
136,819 | <p>I've written a plugin to allow authentication to a WordPress install via an external API. Everything is working except the first and last names are not being set for the new WordPress user created by the plugin when a login attempt passes the external authentication.</p>
<p>Here's the really strange part: one of th... | [
{
"answer_id": 136818,
"author": "Pranay Bhardwaj",
"author_id": 48500,
"author_profile": "https://wordpress.stackexchange.com/users/48500",
"pm_score": 0,
"selected": false,
"text": "<p>You can try:</p>\n\n<pre><code><?php\n $category_ids = get_all_category_ids();\n foreach($catego... | 2014/03/04 | [
"https://wordpress.stackexchange.com/questions/136819",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31649/"
] | I've written a plugin to allow authentication to a WordPress install via an external API. Everything is working except the first and last names are not being set for the new WordPress user created by the plugin when a login attempt passes the external authentication.
Here's the really strange part: one of the selectab... | A custom category walker should do what you need.
```
class My_Cat_Walker extends Walker_Category {
function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
extract($args);
$cat_name = esc_attr( $category->name );
$cat_name = apply_filters( 'list_cats', $cat_name, $category );
... |
136,826 | <p>In the old WordPress that I had, the writer (a type of user that could not publish) was, after an article was schedule, unable to go back to the article and edit it. But now in WordPress 8.1 they (the writers) are able to go back and edit a schedule article. Is there a way to stop this?</p>
<p>writer = contributor<... | [
{
"answer_id": 136839,
"author": "fischi",
"author_id": 15680,
"author_profile": "https://wordpress.stackexchange.com/users/15680",
"pm_score": 0,
"selected": false,
"text": "<p>Whew, that one was hard to solve ;-) However, the thing is, you have to dig deep here.</p>\n\n<p>The function ... | 2014/03/04 | [
"https://wordpress.stackexchange.com/questions/136826",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36110/"
] | In the old WordPress that I had, the writer (a type of user that could not publish) was, after an article was schedule, unable to go back to the article and edit it. But now in WordPress 8.1 they (the writers) are able to go back and edit a schedule article. Is there a way to stop this?
writer = contributor | Me, like **@fischi** think that filter `'user_has_cap'` is the best choiche for the pourpose, however, I think that is better to the work, regardless the $\_GET post or action: WordPress check the meta cabability on a per-post basis, using an additional argument.
In few words, when filtering `'user_has_cap'` for a met... |
136,833 | <p>There's a post count in the user page of the WordPress admin area. I have a custom post type events. Is there some hook I can use to add my event count to the post count, or else to add a column for the event count?</p>
| [
{
"answer_id": 136842,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 4,
"selected": true,
"text": "<p>There are 2 pretty undocumented hooks <code>'manage_users_custom_column'</code> and <code>'manage_users_column... | 2014/03/04 | [
"https://wordpress.stackexchange.com/questions/136833",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28916/"
] | There's a post count in the user page of the WordPress admin area. I have a custom post type events. Is there some hook I can use to add my event count to the post count, or else to add a column for the event count? | There are 2 pretty undocumented hooks `'manage_users_custom_column'` and `'manage_users_columns'` that you can use for the scope.
They works in same manner of `'manage_posts_custom_column'` and `'manage_posts_columns'` that are better documented, see [Codex](http://codex.wordpress.org/Plugin_API/Filter_Reference/manag... |
136,836 | <p>I have the following rewrite tags defined:</p>
<pre><code>// ADD REWRITE TAG FOR 'VEHICLE MAKES'
add_rewrite_tag('%make%','([^&]+)');
// ADD REWRITE TAG FOR 'BODY STYLES'
add_rewrite_tag('%body-style%','([^&]+)');
// ADD REWRITE TAG FOR 'OTHER TOPICS'
add_rewrite_tag('%topic%','([^&]+)');
</code></pre... | [
{
"answer_id": 136864,
"author": "Nishant Kumar",
"author_id": 35855,
"author_profile": "https://wordpress.stackexchange.com/users/35855",
"pm_score": -1,
"selected": false,
"text": "<p>Before asking any question here, please try to find it out yourself. In case of wordpress you should l... | 2014/03/04 | [
"https://wordpress.stackexchange.com/questions/136836",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31784/"
] | I have the following rewrite tags defined:
```
// ADD REWRITE TAG FOR 'VEHICLE MAKES'
add_rewrite_tag('%make%','([^&]+)');
// ADD REWRITE TAG FOR 'BODY STYLES'
add_rewrite_tag('%body-style%','([^&]+)');
// ADD REWRITE TAG FOR 'OTHER TOPICS'
add_rewrite_tag('%topic%','([^&]+)');
```
I'm trying to create a custom re... | Have you tried adding the third parameter to that call?
`add_rewrite_tag( '%make%', '([^/]+)', 'make=' );` |
136,861 | <p>Is it possible to start the loop from a certain post ID? I would like to get all the post starting at a certain ID, decendingly. To explain, I have to make some assumptions first.</p>
<p>Assume that my WordPress database has 20 posts. Obviously, each post will have an ID, and assume that the IDs for those posts pos... | [
{
"answer_id": 137087,
"author": "Stephen S.",
"author_id": 5019,
"author_profile": "https://wordpress.stackexchange.com/users/5019",
"pm_score": 0,
"selected": false,
"text": "<p>Would using the <code>offset</code> parameter work for your needs?</p>\n\n<pre><code>$args = array(\n 'po... | 2014/03/05 | [
"https://wordpress.stackexchange.com/questions/136861",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34253/"
] | Is it possible to start the loop from a certain post ID? I would like to get all the post starting at a certain ID, decendingly. To explain, I have to make some assumptions first.
Assume that my WordPress database has 20 posts. Obviously, each post will have an ID, and assume that the IDs for those posts posts range f... | You can use posts\_where hook to achieve this
```
add_filter( 'posts_where' , 'posts_where' );
function posts_where( $where ) {
global $wpdb;
$start = $query->get('ID_VARIABLE_HERE');
// add any condition if you have
if ( ! is_admin() && $query->is_main_query()){
$where .= " AND {$wpdb->pos... |
136,871 | <p>In the WordPress <a href="http://codex.wordpress.org/Function_Reference/WP_List_Table" rel="nofollow">codex</a>, following is highlighted in red for <code>WP List Table</code>.</p>
<blockquote>
<p>"This class's access is marked as private. That means it is not intended for use by plugin and theme developers as it... | [
{
"answer_id": 137087,
"author": "Stephen S.",
"author_id": 5019,
"author_profile": "https://wordpress.stackexchange.com/users/5019",
"pm_score": 0,
"selected": false,
"text": "<p>Would using the <code>offset</code> parameter work for your needs?</p>\n\n<pre><code>$args = array(\n 'po... | 2014/03/05 | [
"https://wordpress.stackexchange.com/questions/136871",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43570/"
] | In the WordPress [codex](http://codex.wordpress.org/Function_Reference/WP_List_Table), following is highlighted in red for `WP List Table`.
>
> "This class's access is marked as private. That means it is not intended for use by plugin and theme developers as it is subject to change without warning in any future WordP... | You can use posts\_where hook to achieve this
```
add_filter( 'posts_where' , 'posts_where' );
function posts_where( $where ) {
global $wpdb;
$start = $query->get('ID_VARIABLE_HERE');
// add any condition if you have
if ( ! is_admin() && $query->is_main_query()){
$where .= " AND {$wpdb->pos... |
136,894 | <p>Active plugin PHP files are interpreted automatically when you view a page, post, admin page, etc.</p>
<p>I could also run a plugin PHP directly if I knew the fully qualified URL, however it will most likely throw errors as non of the Wordpress functions will have been included.</p>
<p>How would I test if a plugin... | [
{
"answer_id": 136899,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 2,
"selected": false,
"text": "<p>There are a lot of way, you can look at a WordPress constant, or a WordPress function...</p>\n\n<p>Examples:<... | 2014/03/05 | [
"https://wordpress.stackexchange.com/questions/136894",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37218/"
] | Active plugin PHP files are interpreted automatically when you view a page, post, admin page, etc.
I could also run a plugin PHP directly if I knew the fully qualified URL, however it will most likely throw errors as non of the Wordpress functions will have been included.
How would I test if a plugins PHP page has be... | You should never need to send a user or a form or an AJAX request directly to a plugin files URL.
**If you're submitting a form**, no new URL is needed at all, simply:
```
if ( !empty( $_POST['formfield'] ) {
// handle form submission and print thank you
} else {
// display form
}
```
Or as most people do, ... |
136,896 | <p>I guess the title says all. I'm trying to change the search icon of the twenty fourteen theme, because I need a darker one.</p>
<p>I tried like this:</p>
<pre><code>.search-toggle {
background: url('http://www.citizen-science.at/wordpress/wp-content/themes/cs/img/search-icon.png');
}
</code></pre>
<p>... | [
{
"answer_id": 136901,
"author": "fischi",
"author_id": 15680,
"author_profile": "https://wordpress.stackexchange.com/users/15680",
"pm_score": 2,
"selected": true,
"text": "<p>This is more of a simple CSS question than actually related to WordPress.</p>\n\n<p>However, you need to change... | 2014/03/05 | [
"https://wordpress.stackexchange.com/questions/136896",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45158/"
] | I guess the title says all. I'm trying to change the search icon of the twenty fourteen theme, because I need a darker one.
I tried like this:
```
.search-toggle {
background: url('http://www.citizen-science.at/wordpress/wp-content/themes/cs/img/search-icon.png');
}
```
which results in nothing. | This is more of a simple CSS question than actually related to WordPress.
However, you need to change your `style.css`. As TwentyFourteen does not use images, but pseudo css-classes, you need to change this as well:
```
.search-toggle {
background: #fff url('http://www.citizen-science.at/wordpress/wp-content/them... |
136,900 | <p>I have a loop definition like this in <code>functions.php</code>:</p>
<pre><code>function artist_list($query) {
if ( is_admin() || ! $query->is_main_query() ) {
return;
}
// Target the artists page
if (is_tax('artist-category')) {
$query->set('posts_per_page', '-1');
$q... | [
{
"answer_id": 136901,
"author": "fischi",
"author_id": 15680,
"author_profile": "https://wordpress.stackexchange.com/users/15680",
"pm_score": 2,
"selected": true,
"text": "<p>This is more of a simple CSS question than actually related to WordPress.</p>\n\n<p>However, you need to change... | 2014/03/05 | [
"https://wordpress.stackexchange.com/questions/136900",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8698/"
] | I have a loop definition like this in `functions.php`:
```
function artist_list($query) {
if ( is_admin() || ! $query->is_main_query() ) {
return;
}
// Target the artists page
if (is_tax('artist-category')) {
$query->set('posts_per_page', '-1');
$query->set('orderby', 'meta_valu... | This is more of a simple CSS question than actually related to WordPress.
However, you need to change your `style.css`. As TwentyFourteen does not use images, but pseudo css-classes, you need to change this as well:
```
.search-toggle {
background: #fff url('http://www.citizen-science.at/wordpress/wp-content/them... |
136,934 | <p>Im currently building a plugin that imports some data from an XML feed. This is all working great. Now i want to add some info, letting the user know when the last import happened. "Last import: 03/10/2014" </p>
<p>How should i save that data? does wordpress provide plugin meta in the database or should it go into ... | [
{
"answer_id": 136901,
"author": "fischi",
"author_id": 15680,
"author_profile": "https://wordpress.stackexchange.com/users/15680",
"pm_score": 2,
"selected": true,
"text": "<p>This is more of a simple CSS question than actually related to WordPress.</p>\n\n<p>However, you need to change... | 2014/03/05 | [
"https://wordpress.stackexchange.com/questions/136934",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38440/"
] | Im currently building a plugin that imports some data from an XML feed. This is all working great. Now i want to add some info, letting the user know when the last import happened. "Last import: 03/10/2014"
How should i save that data? does wordpress provide plugin meta in the database or should it go into the option... | This is more of a simple CSS question than actually related to WordPress.
However, you need to change your `style.css`. As TwentyFourteen does not use images, but pseudo css-classes, you need to change this as well:
```
.search-toggle {
background: #fff url('http://www.citizen-science.at/wordpress/wp-content/them... |
136,950 | <p>I would like to have the following taxonomy structure:</p>
<pre><code>site.com/courses/course-name/pathway/pathway-name
</code></pre>
<p>The domain is such that any particular course can be completed by taking a number of different pathways - different module structures.</p>
<p>The following URLS would work as su... | [
{
"answer_id": 136966,
"author": "Harry",
"author_id": 48046,
"author_profile": "https://wordpress.stackexchange.com/users/48046",
"pm_score": 0,
"selected": false,
"text": "<p>I ended up using <a href=\"https://wordpress.org/plugins/subordinate-post-type-helpers/\" rel=\"nofollow\">Subo... | 2014/03/05 | [
"https://wordpress.stackexchange.com/questions/136950",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48046/"
] | I would like to have the following taxonomy structure:
```
site.com/courses/course-name/pathway/pathway-name
```
The domain is such that any particular course can be completed by taking a number of different pathways - different module structures.
The following URLS would work as such:
```
site.com/courses
```
s... | I ended up using [Subordinate Post Type Helpers plugin](https://wordpress.org/plugins/subordinate-post-type-helpers/) to create relationships between two distinct custom post types: `courses` and `pathways` |
136,953 | <p>When the user clicks the 'submit' button on my form, I would like 'this will be echoed back' to be displayed within an alert.</p>
<p>The only JS console error I get: </p>
<p><code>Failed to load resource http://nikkomsgchannel/e?0017005e002b00560036004400190026002d0025002c005300…240020003700620024005b004a005500790... | [
{
"answer_id": 136969,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 0,
"selected": false,
"text": "<p>There are lots of problems: </p>\n\n<p>Don't <code>echo</code> things in the AJAX callback. JavaScript should hand... | 2014/03/05 | [
"https://wordpress.stackexchange.com/questions/136953",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | When the user clicks the 'submit' button on my form, I would like 'this will be echoed back' to be displayed within an alert.
The only JS console error I get:
`Failed to load resource http://nikkomsgchannel/e?0017005e002b00560036004400190026002d0025002c005300…240020003700620024005b004a005500790053002c0045002b0036003... | That error was identified by stackoverflow - it's actually caused by Rapport software, a security tool some banks recommend. You could turn it off / remove it from development machines. |
137,010 | <p>For some reason my default password nag is playing up on a big multi-user site I've setup. Pretty sure it's got to do with the <a href="http://picklewagon.com/wordpress/new-user-approve/" rel="nofollow">New User Approve</a> and <a href="http://www.gravityforms.com/add-ons/user-registration/" rel="nofollow">Gravity F... | [
{
"answer_id": 136974,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 3,
"selected": true,
"text": "<p>What you are seeing is probably produced by <a href=\"http://queryposts.com/function/_admin_bar_bump_cb/\" rel=\"nof... | 2014/03/06 | [
"https://wordpress.stackexchange.com/questions/137010",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48568/"
] | For some reason my default password nag is playing up on a big multi-user site I've setup. Pretty sure it's got to do with the [New User Approve](http://picklewagon.com/wordpress/new-user-approve/) and [Gravity Forms User Rego](http://www.gravityforms.com/add-ons/user-registration/) combo that I'm using.
Anyway, probl... | What you are seeing is probably produced by [`_admin_bar_bump_cb()`](http://queryposts.com/function/_admin_bar_bump_cb/).
From quick look at code it includes following instructions [inline in `WP_Admin_Bar` class](https://core.trac.wordpress.org/browser/branches/3.8/src/wp-includes/class-wp-admin-bar.php#L48):
>
> T... |
137,019 | <p>So for now, every iteration looks the same and it's been a while since I dealt with php so could you help me? </p>
<pre><code> <?php
$pages = get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=desc');
$count = 0;
foreach($pages as $page)
{
$content = $page->post_content;
i... | [
{
"answer_id": 136974,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 3,
"selected": true,
"text": "<p>What you are seeing is probably produced by <a href=\"http://queryposts.com/function/_admin_bar_bump_cb/\" rel=\"nof... | 2014/03/06 | [
"https://wordpress.stackexchange.com/questions/137019",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48576/"
] | So for now, every iteration looks the same and it's been a while since I dealt with php so could you help me?
```
<?php
$pages = get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=desc');
$count = 0;
foreach($pages as $page)
{
$content = $page->post_content;
if(!$content)
continue;
... | What you are seeing is probably produced by [`_admin_bar_bump_cb()`](http://queryposts.com/function/_admin_bar_bump_cb/).
From quick look at code it includes following instructions [inline in `WP_Admin_Bar` class](https://core.trac.wordpress.org/browser/branches/3.8/src/wp-includes/class-wp-admin-bar.php#L48):
>
> T... |
137,040 | <p>I'm trying to create a related posts WP_Query. So far, I've to created a custom WP_Query that queries all posts that match an array of tags.</p>
<p>However, I'm trying to create a simple <code>if statement</code>: if the number of posts fetched are <strong>less than 10</strong>, get the remainder from <strong>elsew... | [
{
"answer_id": 137043,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 3,
"selected": false,
"text": "<p>You could do something like :</p>\n\n<pre><code>$related_posts_query = new WP_Query( $related_posts_args );\n... | 2014/03/06 | [
"https://wordpress.stackexchange.com/questions/137040",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33541/"
] | I'm trying to create a related posts WP\_Query. So far, I've to created a custom WP\_Query that queries all posts that match an array of tags.
However, I'm trying to create a simple `if statement`: if the number of posts fetched are **less than 10**, get the remainder from **elsewhere** (this could be from a particula... | You could do something like :
```
$related_posts_query = new WP_Query( $related_posts_args );
if( $related_posts_query->found_posts < 10 ){
$args = array(/* new wp_query args*/);
$newquery = new WP_Query( $args );
}
# merge the two results
$related_posts_query->posts = array_merge( $related_posts_query->posts, ... |
137,049 | <p>Im wondering if anyone can point me in the direction of how to create a plugin with add-ons. It looks like the approach is first to create a plugin with the core feature, and then write other plugins that interact with the main plugin. But for some reason its impossible to google, as all my queries brings out plugin... | [
{
"answer_id": 137050,
"author": "Jonathan",
"author_id": 48491,
"author_profile": "https://wordpress.stackexchange.com/users/48491",
"pm_score": -1,
"selected": false,
"text": "<p>Well, you could build an add-on functionality into your plugin where you can upload a .zip file and unpack ... | 2014/03/06 | [
"https://wordpress.stackexchange.com/questions/137049",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38440/"
] | Im wondering if anyone can point me in the direction of how to create a plugin with add-ons. It looks like the approach is first to create a plugin with the core feature, and then write other plugins that interact with the main plugin. But for some reason its impossible to google, as all my queries brings out plugins f... | You could implement filters and actions in your core plugin's code, at the appropriate places where you want your addons to interact, by using:
```
do_action( 'my_action');
apply_filters('my_filter', $value, $variable_to_pass, $another_variable_to_pass);
```
Then you can have addons as separate plugins and have them... |
137,051 | <p>Here is the problem I am having:</p>
<ol>
<li>I have a custom post type called "weddingguests"</li>
<li>This custom post type "weddingguests" has a custom taxonomy, "friendsof", hierarchic</li>
<li>I want to programmatically insert into this custom taxonomy "friendsof" 2 terms: "Friends of the Bride" and "Friends o... | [
{
"answer_id": 137070,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>While I don't know <em>why</em> and don't have time to investigate right now, the hook you've chosen is too ... | 2014/03/06 | [
"https://wordpress.stackexchange.com/questions/137051",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10275/"
] | Here is the problem I am having:
1. I have a custom post type called "weddingguests"
2. This custom post type "weddingguests" has a custom taxonomy, "friendsof", hierarchic
3. I want to programmatically insert into this custom taxonomy "friendsof" 2 terms: "Friends of the Bride" and "Friends of the Groom"
Here is the... | While I don't know *why* and don't have time to investigate right now, the hook you've chosen is too early. Your code works if you use, for example, `init` instead of `after_setup_theme`.
In addition, as written, your code runs on every page load which is a bit profligate. There should be a way execute this only on p... |
137,093 | <p>It's quite hard to put a title on this question.
So the problem is if my page title is "BLA BLA" my href link will not work.</p>
<pre><code><a href="#<?php echo get_the_title();?"> <?php echo get_the_title();?> </a>
</code></pre>
<p>It could be great if it automatically translate it to </p>
... | [
{
"answer_id": 137095,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>The Core functions <a href=\"http://codex.wordpress.org/Function_Reference/the_permalink#Description\" rel=\... | 2014/03/06 | [
"https://wordpress.stackexchange.com/questions/137093",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48576/"
] | It's quite hard to put a title on this question.
So the problem is if my page title is "BLA BLA" my href link will not work.
```
<a href="#<?php echo get_the_title();?"> <?php echo get_the_title();?> </a>
```
It could be great if it automatically translate it to
```
bla bla
```
so I'll have
```
href=#... | The Core functions [`the_permalink()`](http://codex.wordpress.org/Function_Reference/the_permalink#Description), and [`get_permalink()`](http://codex.wordpress.org/Function_Reference/get_permalink#Description) are built to do what you are trying to hack together manually. Those will provide a complete URL for the link.... |
137,100 | <p>Is there a way to use pagination on a page query like with posts?</p>
<p>Here is the code I'm using:</p>
<pre><code> $listingPages = get_posts(
array(
'cild_of' => '7',
'meta_key' => 'Type',
'post_type' => 'page',
'post_status' => 'publish',
'orderby' => '... | [
{
"answer_id": 137118,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 3,
"selected": true,
"text": "<p>You should check your code because you have some sentences that will make your pagination function returns emp... | 2014/03/06 | [
"https://wordpress.stackexchange.com/questions/137100",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48606/"
] | Is there a way to use pagination on a page query like with posts?
Here is the code I'm using:
```
$listingPages = get_posts(
array(
'cild_of' => '7',
'meta_key' => 'Type',
'post_type' => 'page',
'post_status' => 'publish',
'orderby' => 'meta_value',
'order' => 'ASC... | You should check your code because you have some sentences that will make your pagination function returns empty value. For example, the next piece of code will get you out because you are in a page template, so is\_singular() returns `true`:
```
if( is_singular() )
return;
```
Also, you are using the global `$w... |
137,103 | <p>I might be misreading but I can't find a solution to the following need: I want to install WordPress in a subfolder of my <code>www</code> directory, let's say <code>www/wp</code>. I then want to add two blogs to the multisite network called <em>foo</em> and <em>bar</em>. When I do so, they end up with the URL:</p>
... | [
{
"answer_id": 137118,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 3,
"selected": true,
"text": "<p>You should check your code because you have some sentences that will make your pagination function returns emp... | 2014/03/06 | [
"https://wordpress.stackexchange.com/questions/137103",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22803/"
] | I might be misreading but I can't find a solution to the following need: I want to install WordPress in a subfolder of my `www` directory, let's say `www/wp`. I then want to add two blogs to the multisite network called *foo* and *bar*. When I do so, they end up with the URL:
* http://example.com/wp/foo
* http://examp... | You should check your code because you have some sentences that will make your pagination function returns empty value. For example, the next piece of code will get you out because you are in a page template, so is\_singular() returns `true`:
```
if( is_singular() )
return;
```
Also, you are using the global `$w... |
137,143 | <p>Thank you in advance for any help you might provide. I have read many other posts, and unfortunately the provided solutions did not work.</p>
<p>The problem is this: I have Wordpress installed in a supdirectory
<code>http://www.example.com/wordpress</code> and would like to change the front end url to <code>http... | [
{
"answer_id": 137741,
"author": "suntrop",
"author_id": 47934,
"author_profile": "https://wordpress.stackexchange.com/users/47934",
"pm_score": 0,
"selected": false,
"text": "<p>You are sure there is no other error? I had almost the same problem last winter and after about 4 hours I not... | 2014/03/07 | [
"https://wordpress.stackexchange.com/questions/137143",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48629/"
] | Thank you in advance for any help you might provide. I have read many other posts, and unfortunately the provided solutions did not work.
The problem is this: I have Wordpress installed in a supdirectory
`http://www.example.com/wordpress` and would like to change the front end url to `http://www.example.com/something... | Go to phpMyAdmin and select the database for the website. Go to the "wp\_options" table and edit the first option (option\_name: siteurl) from "<http://www.example.com/wordpress>" to "<http://www.example.com/somethingelse>".
In the same "wp\_options" table, look for "option\_name: home" and change the URL there too.
... |
137,149 | <p>What I want to do is... on a per page/post basis I want to be able to have the H1 say something different then the Title...</p>
<p>This should be such a simple thing, but I've been looking around for an option and searching google for a solution for an hour now, and I can't find anything.</p>
<p>Is there a way to ... | [
{
"answer_id": 137151,
"author": "penguin429",
"author_id": 48105,
"author_profile": "https://wordpress.stackexchange.com/users/48105",
"pm_score": 2,
"selected": false,
"text": "<p>Yes! Custom fields: <a href=\"http://codex.wordpress.org/Custom_Fields\" rel=\"nofollow\">http://codex.wor... | 2014/03/07 | [
"https://wordpress.stackexchange.com/questions/137149",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48632/"
] | What I want to do is... on a per page/post basis I want to be able to have the H1 say something different then the Title...
This should be such a simple thing, but I've been looking around for an option and searching google for a solution for an hour now, and I can't find anything.
Is there a way to do this in Wordpr... | Yes! Custom fields: <http://codex.wordpress.org/Custom_Fields>
You can create alternate post titles via the post editor, and then you can display them with some minor adjustments to the `single.php` and `index.php` templates (or `{$post_type}-archive.php` templates, if you have them). For example:
```
<?php $post_tit... |
137,156 | <p>I am working on a custom search by meta value and using this:</p>
<pre><code>print_r($_REQUEST);
$args = array(
'post_type' => 'property_post',
'posts_per_page' => 10,
'order' => 'ASC',
'meta_query' => array(
'relation' => 'OR',
array(
... | [
{
"answer_id": 137181,
"author": "sri",
"author_id": 34200,
"author_profile": "https://wordpress.stackexchange.com/users/34200",
"pm_score": 0,
"selected": false,
"text": "<p>The problem is when you have a string variable Wordpress doesn't automatically add quotes to the variable and the... | 2014/03/07 | [
"https://wordpress.stackexchange.com/questions/137156",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38118/"
] | I am working on a custom search by meta value and using this:
```
print_r($_REQUEST);
$args = array(
'post_type' => 'property_post',
'posts_per_page' => 10,
'order' => 'ASC',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'cust... | First of all, one never should rely on *raw* `$_REQUEST`: believe me, this is a security issue.
PHP has 2 functions: [`filter_input`](http://www.php.net/manual/en/function.filter-input.php) and [`filter_input_array`](http://www.php.net/manual/en/function.filter-input-array.php) that helps you to sanitize your request ... |
137,166 | <p>I'm trying to schedule event on hourly basis but it doesn't work. Why, I can't understand.</p>
<p>Here is a function that i use to schedule event.</p>
<pre><code>add_action( 'scheduled_update_feeds', 'update_feeds', 10, 2 );
function scheduled_activation() {
wp_schedule_event( time(), 'everyhour', 'scheduled_... | [
{
"answer_id": 143457,
"author": "Douglas.Sesar",
"author_id": 19945,
"author_profile": "https://wordpress.stackexchange.com/users/19945",
"pm_score": 2,
"selected": false,
"text": "<p>This is not a fix for your problem, but it might lead you in the right direction to solving the issue. ... | 2014/03/07 | [
"https://wordpress.stackexchange.com/questions/137166",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/21135/"
] | I'm trying to schedule event on hourly basis but it doesn't work. Why, I can't understand.
Here is a function that i use to schedule event.
```
add_action( 'scheduled_update_feeds', 'update_feeds', 10, 2 );
function scheduled_activation() {
wp_schedule_event( time(), 'everyhour', 'scheduled_update_feeds', array(... | This is not a fix for your problem, but it might lead you in the right direction to solving the issue. I would suggest checking out this plugin to possibly help you find out what is going on:
[WP Cron Control](https://wordpress.org/plugins/wp-cron-control/)
It offers a quick view of cron jobs scheduled throughout you... |
137,182 | <p>a post has the following custom fields:</p>
<pre><code>'my_custom_field' => 1
'my_custom_field' => 2
'my_custom_field' => 3
</code></pre>
<p>I now want to query all posts that do NOT contain the value 2 for 'my_custom_field'. I'm trying this:</p>
<pre><code>$args = Array('posts_per_page' => -1,
'p... | [
{
"answer_id": 137209,
"author": "elleeott",
"author_id": 10957,
"author_profile": "https://wordpress.stackexchange.com/users/10957",
"pm_score": 2,
"selected": true,
"text": "<p>This might require writing custom sql with a subquery:</p>\n\n<pre><code>$results = $wpdb->get_results(\"\... | 2014/03/07 | [
"https://wordpress.stackexchange.com/questions/137182",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48654/"
] | a post has the following custom fields:
```
'my_custom_field' => 1
'my_custom_field' => 2
'my_custom_field' => 3
```
I now want to query all posts that do NOT contain the value 2 for 'my\_custom\_field'. I'm trying this:
```
$args = Array('posts_per_page' => -1,
'post_type' => 'page',
'meta_query' => array(... | This might require writing custom sql with a subquery:
```
$results = $wpdb->get_results("
SELECT *
FROM $wpdb->posts
WHERE ID NOT IN (
SELECT post_id FROM $wpdb->postmeta
WHERE meta_key = 'my_custom_field' and meta_value = 2
)
");
```
then just iterate through the results as [described... |
137,184 | <p>I need to insert a post via <code>PHP</code> outside the Wordpress environment (but on the same server) and I'm looking for the most efficient way to do this.</p>
<p>I was thinking about 2 solutions:</p>
<p>1) Using XML-RPC, as explained <a href="http://www.hurricanesoftwares.com/wordpress-xmlrpc-posting-content-f... | [
{
"answer_id": 137186,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>Which one uses less resources?</p>\n</blockquote>\n\n<p>Neither, really.</p>\n\n<blockquot... | 2014/03/07 | [
"https://wordpress.stackexchange.com/questions/137184",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3192/"
] | I need to insert a post via `PHP` outside the Wordpress environment (but on the same server) and I'm looking for the most efficient way to do this.
I was thinking about 2 solutions:
1) Using XML-RPC, as explained [here](http://www.hurricanesoftwares.com/wordpress-xmlrpc-posting-content-from-outside-wordpress-admin-pa... | **If you're on a remote server**, XMLRPC would be best, but requires login details
**If you're in a PHP script on the same server**, `wp-load.php` would be best ( XMLRPC will involve a request of sorts )
**If you're in a bash or CLI script**, WP CLI would be best, e.g.:
```
wp post create --post_type=page --post_sta... |
137,193 | <p>I created a CPT which allows the user to add people to the page. I have already created a page template for displaying all people. This page also displays all categories used for people. My problem: How do I achieve that when the user clicks on a category only people who have this category are displayed?</p>
<p>Her... | [
{
"answer_id": 137186,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>Which one uses less resources?</p>\n</blockquote>\n\n<p>Neither, really.</p>\n\n<blockquot... | 2014/03/07 | [
"https://wordpress.stackexchange.com/questions/137193",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48649/"
] | I created a CPT which allows the user to add people to the page. I have already created a page template for displaying all people. This page also displays all categories used for people. My problem: How do I achieve that when the user clicks on a category only people who have this category are displayed?
Here are the ... | **If you're on a remote server**, XMLRPC would be best, but requires login details
**If you're in a PHP script on the same server**, `wp-load.php` would be best ( XMLRPC will involve a request of sorts )
**If you're in a bash or CLI script**, WP CLI would be best, e.g.:
```
wp post create --post_type=page --post_sta... |
137,197 | <p>I'm trying to create a custom post type that's supposed to be used for a publication issue -> article structure. Since the hierarchical structure is <a href="http://codex.wordpress.org/Function_Reference/register_post_type" rel="nofollow">really only meant for pages</a> (refer to <code>hierarchical</code> section's ... | [
{
"answer_id": 137198,
"author": "Nathan Fitzgerald - Fitzgenius",
"author_id": 7025,
"author_profile": "https://wordpress.stackexchange.com/users/7025",
"pm_score": 2,
"selected": false,
"text": "<p>I've taken this from another site I have made which uses the hierarchical structure and ... | 2014/03/07 | [
"https://wordpress.stackexchange.com/questions/137197",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48662/"
] | I'm trying to create a custom post type that's supposed to be used for a publication issue -> article structure. Since the hierarchical structure is [really only meant for pages](http://codex.wordpress.org/Function_Reference/register_post_type) (refer to `hierarchical` section's note), I figured I'd configure the custo... | I've taken this from another site I have made which uses the hierarchical structure and it works. (I have amended to fit your post type)
```
function register_publications_cpt() {
$labels = array(
'name' => _x('Publications', 'post type general name'),
'singular_name' => _x('Publicatio... |
137,236 | <p>Wordpress newbie, here.</p>
<p>I've created a custom post type, using CPT UI, named "menus". Later created single instances of that "menus" CPT, directed by a "single-menu" template.</p>
<p>So here's my hierarchy for that "menu" CPT:</p>
<p>one template "menus" : listing all "menu" posts
one template "single-menu... | [
{
"answer_id": 137205,
"author": "EHerman",
"author_id": 43000,
"author_profile": "https://wordpress.stackexchange.com/users/43000",
"pm_score": 0,
"selected": false,
"text": "<p>I prefer to keep all of my support threads in a centered location. It just seems easier to manage. With that ... | 2014/03/07 | [
"https://wordpress.stackexchange.com/questions/137236",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48672/"
] | Wordpress newbie, here.
I've created a custom post type, using CPT UI, named "menus". Later created single instances of that "menus" CPT, directed by a "single-menu" template.
So here's my hierarchy for that "menu" CPT:
one template "menus" : listing all "menu" posts
one template "single-menu" : generating individua... | All my support forums are on WordPress.org, but I do all my development on GitHub and that has led to a few support issues filtering in to the issues stream that are support issues and not bug reports. I also got a handful of people commenting on my blog for support, but I closed all the plugin-related blog posts. I di... |
137,268 | <p>I am developing a solution which is selling a service (can not be categorized as product) I have developed custom post types and taxonomies but I do not want to re-invent the wheel by adding payment gateways just for this purpose. Is there any way I can customize the "Product" post type in any existing ecommerce plu... | [
{
"answer_id": 137291,
"author": "helgatheviking",
"author_id": 6477,
"author_profile": "https://wordpress.stackexchange.com/users/6477",
"pm_score": 2,
"selected": false,
"text": "<p>If you're post type is called 'product' then if you remove the code that registers your post type, and a... | 2014/03/08 | [
"https://wordpress.stackexchange.com/questions/137268",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18193/"
] | I am developing a solution which is selling a service (can not be categorized as product) I have developed custom post types and taxonomies but I do not want to re-invent the wheel by adding payment gateways just for this purpose. Is there any way I can customize the "Product" post type in any existing ecommerce plugin... | You should download en use WooCommerce with buildin payment gateways
You can add a product type with something like:
```
function my_add_product_type( $types ) {
return $types["service"] = "Service";
}
add_filter( "product_type_selector", "my_add_product_type" );
``` |
137,279 | <p>I'm developing a WP plugin which uses custom post types and meta data. What I'm trying to achieve is having the meta data searchable. Here is some code that I found which searches the meta data fine, however I can't get it to display the search string on the CPT page.</p>
<p><img src="https://i.stack.imgur.com/5ZAs... | [
{
"answer_id": 137288,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 0,
"selected": false,
"text": "<p>The code you found modifies the main query on <code>pre_get_posts</code> and unsets the search terms so <code>WP_Q... | 2014/03/08 | [
"https://wordpress.stackexchange.com/questions/137279",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48678/"
] | I'm developing a WP plugin which uses custom post types and meta data. What I'm trying to achieve is having the meta data searchable. Here is some code that I found which searches the meta data fine, however I can't get it to display the search string on the CPT page.
 );
```
which runs [pre... |
137,304 | <p>I have over 8,000 posts generated by wp-o-matic and I want to get rid of all of them. </p>
<p>I want to execute this query in phpMyAdmin. I just want to make sure this is safe to run and it's not wiping out my pages. This is the query:</p>
<pre><code>DELETE FROM 'wp_posts' WHERE 'post_type' = 'post'
</code></pre>
... | [
{
"answer_id": 137309,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>Don't try to do this with <code>SQL</code>. There is post information is multiple tables. You will end up wi... | 2014/03/08 | [
"https://wordpress.stackexchange.com/questions/137304",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27463/"
] | I have over 8,000 posts generated by wp-o-matic and I want to get rid of all of them.
I want to execute this query in phpMyAdmin. I just want to make sure this is safe to run and it's not wiping out my pages. This is the query:
```
DELETE FROM 'wp_posts' WHERE 'post_type' = 'post'
```
Thanks | The join isn't that complex, but I wouldn't bother with it. Since you have a lot to remove a direct SQL query will run a LOT faster than WP.
However, we do need to keep track of the post ID numbers and remove the descendants and metadata.
Not tested / Make a backup / your risk etc. etc.
```
create temporary table `c... |
137,311 | <p>I'm now writing a plugin that hook with a [TAG] on a page. From now every thing work well except for the custom css. I've writing my plugin on a developement station with basic theme (20-14 I think). When I've put my plugin in the real site, that was very ugly because site theme css where not handle. There is a way ... | [
{
"answer_id": 137313,
"author": "Sormano",
"author_id": 48607,
"author_profile": "https://wordpress.stackexchange.com/users/48607",
"pm_score": 0,
"selected": false,
"text": "<p>You should probaby use </p>\n\n<pre><code>wp_dequeue_style();\n</code></pre>\n"
},
{
"answer_id": 137... | 2014/03/08 | [
"https://wordpress.stackexchange.com/questions/137311",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48697/"
] | I'm now writing a plugin that hook with a [TAG] on a page. From now every thing work well except for the custom css. I've writing my plugin on a developement station with basic theme (20-14 I think). When I've put my plugin in the real site, that was very ugly because site theme css where not handle. There is a way to ... | You can try this function.
```
function remove_all_theme_styles() {
global $wp_styles;
$wp_styles->queue = array();
}
add_action('wp_print_styles', 'remove_all_theme_styles', 100);
```
This should work on any theme, but its not really a good approach to disable theme css just to make your plugin look good. |
137,354 | <p>I want to include custom post type in the author arhive page. I tried the method discussed in this post:</p>
<blockquote>
<p><a href="https://wordpress.stackexchange.com/questions/11210/including-post-type-wiki-in-author-archives">Including post_type = 'wiki' in author archives</a></p>
</blockquote>
<pre... | [
{
"answer_id": 137359,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 0,
"selected": false,
"text": "<p>Simply said, the <code>$query</code> argument inside <code>pre_get_posts</code> refers to the <code>WP_Query</code... | 2014/03/09 | [
"https://wordpress.stackexchange.com/questions/137354",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47634/"
] | I want to include custom post type in the author arhive page. I tried the method discussed in this post:
>
> [Including post\_type = 'wiki' in author archives](https://wordpress.stackexchange.com/questions/11210/including-post-type-wiki-in-author-archives)
>
>
>
```
add_action( 'pre_get_posts', 'custom_post_autho... | As Kaiser mentioned, the `post_type` parameter can accept an array of post types. Updating the function to use `is_main_query()` to limit the filter to only the "main" query, the code would look like:
```
add_action( 'pre_get_posts', 'custom_post_author_archive' );
function custom_post_author_archive( $query )
{
i... |
137,374 | <p>I'm developing a simple plug in and I need to filter single_cat_title in category page adding some html in every category page.</p>
<p>Just doing this:</p>
<pre><code>function subtitleCategory ($title) {
return $title."</div></div></div><div class=\"container_24\"><h2 id=\"category-s... | [
{
"answer_id": 137359,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 0,
"selected": false,
"text": "<p>Simply said, the <code>$query</code> argument inside <code>pre_get_posts</code> refers to the <code>WP_Query</code... | 2014/03/09 | [
"https://wordpress.stackexchange.com/questions/137374",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29219/"
] | I'm developing a simple plug in and I need to filter single\_cat\_title in category page adding some html in every category page.
Just doing this:
```
function subtitleCategory ($title) {
return $title."</div></div></div><div class=\"container_24\"><h2 id=\"category-subtitle\">TEST1</h2></div>";
}
add_filter('si... | As Kaiser mentioned, the `post_type` parameter can accept an array of post types. Updating the function to use `is_main_query()` to limit the filter to only the "main" query, the code would look like:
```
add_action( 'pre_get_posts', 'custom_post_author_archive' );
function custom_post_author_archive( $query )
{
i... |
137,394 | <p>I have a theme for my mobile site that requires the <code><!--more--></code> tag in my posts for it to display an excerpt of my post's content. </p>
<p>I've got over 2000 posts already, and its going to take forever to add the tag in all my posts. I don't want to use a plugin, cause I've used one that wasn't ... | [
{
"answer_id": 137675,
"author": "Maruti Mohanty",
"author_id": 37890,
"author_profile": "https://wordpress.stackexchange.com/users/37890",
"pm_score": 1,
"selected": false,
"text": "<p>If you want to control the string count, then you can do it by the following.</p>\n\n<p>Put the below ... | 2014/03/09 | [
"https://wordpress.stackexchange.com/questions/137394",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48112/"
] | I have a theme for my mobile site that requires the `<!--more-->` tag in my posts for it to display an excerpt of my post's content.
I've got over 2000 posts already, and its going to take forever to add the tag in all my posts. I don't want to use a plugin, cause I've used one that wasn't stable at all.
I just nee... | If you want to control the string count, then you can do it by the following.
Put the below code in the active theme's **functions.php** file:--
```
function custom_excerpt_length( $length ) {
return 20; // You can change the number here as per your need.
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 9... |