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 |
|---|---|---|---|---|---|---|
113,497 | <p><strong>I created <code>myfile.php</code> with the following content:</strong></p>
<pre><code>global $paged;
if ( get_query_var( 'paged' ) ) {
$paged = get_query_var( 'paged' );
} else if ( get_query_var( 'page' ) ) {
$paged = get_query_var( 'page' );
} else {
$paged = 1;
}
$args = array(
'post_typ... | [
{
"answer_id": 113542,
"author": "Paul",
"author_id": 17167,
"author_profile": "https://wordpress.stackexchange.com/users/17167",
"pm_score": -1,
"selected": false,
"text": "<p>After hours of struggling I found the cause.</p>\n\n<p>The post type that I registered using <code>register_pos... | 2013/09/09 | [
"https://wordpress.stackexchange.com/questions/113497",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17167/"
] | **I created `myfile.php` with the following content:**
```
global $paged;
if ( get_query_var( 'paged' ) ) {
$paged = get_query_var( 'paged' );
} else if ( get_query_var( 'page' ) ) {
$paged = get_query_var( 'page' );
} else {
$paged = 1;
}
$args = array(
'post_type' => array('my_custom_post_type'),
... | I've experienced this with several plugins of my own, while trying to display a numerical pagination for my custom post types and custom taxonomies.
It's my understanding that by using [`WP_Query`](https://codex.wordpress.org/Class_Reference/WP_Query) to fetch posts from the database in your own custom way (other than... |
113,500 | <p>I'm building a site for some army guys to share photos, and one thing keeps stumping me. </p>
<p>They have some photos that they'd like everyone who is signed up for the site to view, and others that just they can view. But they can't be administrators.</p>
<p>The only help I can find is on only allowing certain u... | [
{
"answer_id": 113511,
"author": "Nikolay",
"author_id": 37796,
"author_profile": "https://wordpress.stackexchange.com/users/37796",
"pm_score": 0,
"selected": false,
"text": "<p>Download and install the plug-in <a href=\"http://wordpress.org/plugins/restrict-categories/\" rel=\"nofollow... | 2013/09/09 | [
"https://wordpress.stackexchange.com/questions/113500",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37418/"
] | I'm building a site for some army guys to share photos, and one thing keeps stumping me.
They have some photos that they'd like everyone who is signed up for the site to view, and others that just they can view. But they can't be administrators.
The only help I can find is on only allowing certain user levels to POS... | If I understand you have some categories, eg: 'reserved', 'people', 'landscapes', 'personal' and so on.
Now you want that subscribers can see posts in, e.g. 'people', 'landscapes' categories but not posts in 'reserved' and 'personal' categories.
This is relatively easy, just hook into `pre_get_posts` and if the reque... |
113,501 | <p>Is there some way to avoid the load of default WordPress styles in login screen to only load my custom stylesheets?</p>
<p>Actually I'm using this code:</p>
<pre><code>function login_styles() {
// Sets the styles if is the current theme
if (get_stylesheet_directory() == get_template_directory()) {
... | [
{
"answer_id": 113556,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 1,
"selected": false,
"text": "<p>Following the lead of a G.M. comment in a deleted answer, where he points out that the login styles are pri... | 2013/09/09 | [
"https://wordpress.stackexchange.com/questions/113501",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28898/"
] | Is there some way to avoid the load of default WordPress styles in login screen to only load my custom stylesheets?
Actually I'm using this code:
```
function login_styles() {
// Sets the styles if is the current theme
if (get_stylesheet_directory() == get_template_directory()) {
// Prints link to sty... | Using `wp_deregister_style( 'login' )` to remove the login styles will still result in a 404'd request for the login CSS file. However, if you re-register the login style after deregistering it you can prevent the unwanted request.
```
add_action( 'login_init', function() {
wp_deregister_style( 'login' );
wp_r... |
113,509 | <p>I am building a wordpress theme with a theme dashboard with options, but as I read somewhere, the enqueue script code I am using just enqueues it in the backend but it loads in every page in the backend. So I am having some js conflicts...</p>
<p>I have this code:</p>
<pre><code>add_menu_page($themename, $themenam... | [
{
"answer_id": 113512,
"author": "Doug Cassidy",
"author_id": 17881,
"author_profile": "https://wordpress.stackexchange.com/users/17881",
"pm_score": 1,
"selected": false,
"text": "<p>Look at the URL of the page you want to enqueue the js into. It might be sth like</p>\n\n<pre><code>/wp... | 2013/09/09 | [
"https://wordpress.stackexchange.com/questions/113509",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34034/"
] | I am building a wordpress theme with a theme dashboard with options, but as I read somewhere, the enqueue script code I am using just enqueues it in the backend but it loads in every page in the backend. So I am having some js conflicts...
I have this code:
```
add_menu_page($themename, $themename, 'administrator', b... | Inside `admin-header.php`, there's the following set of hooks:
```
do_action('admin_enqueue_scripts', $hook_suffix);
do_action("admin_print_styles-$hook_suffix");
do_action('admin_print_styles');
do_action("admin_print_scripts-$hook_suffix");
do_action('admin_print_scripts');
do_action("admin_head-$hook_suffix");
do_a... |
113,516 | <p>I'm trying to associate an existing image from the media library with a post (It's a custom post type), If I use <code>wp_insert_attachment</code> I get a duplicate in the media library, so I'm getting the image <code>id</code> and using that as the <code>attach_id</code>.</p>
<pre><code>$attach_id = intval( $file[... | [
{
"answer_id": 113538,
"author": "Ben Miller - Remember Monica",
"author_id": 32110,
"author_profile": "https://wordpress.stackexchange.com/users/32110",
"pm_score": 3,
"selected": true,
"text": "<p>You can modify an existing media library image using <a href=\"http://codex.wordpress.org... | 2013/09/09 | [
"https://wordpress.stackexchange.com/questions/113516",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37798/"
] | I'm trying to associate an existing image from the media library with a post (It's a custom post type), If I use `wp_insert_attachment` I get a duplicate in the media library, so I'm getting the image `id` and using that as the `attach_id`.
```
$attach_id = intval( $file['id'] );
$attach_data = wp_generate_attachment_... | You can modify an existing media library image using [`wp_insert_attachment`](http://codex.wordpress.org/Function_Reference/wp_insert_attachment) by setting the `ID` key in the parameter array.
```
$attachment = array(
'ID' => $existing_library_attachment_id,
'post_parent' => $custom_post_id
);
wp_insert_attac... |
113,534 | <p>I want to execute a query like this:</p>
<pre><code>$wpdb->prepare( "SELECT * ... from ... WHERE ( post_title LIKE '%%%s%%' or post_content LIKE '%%%s%%' )..., $string );
</code></pre>
<p>If I do the query with only one condition it works:</p>
<pre><code>$wpdb->prepare( "SELECT * ... from ... WHERE ( post_t... | [
{
"answer_id": 113539,
"author": "Charles Clarkson",
"author_id": 31788,
"author_profile": "https://wordpress.stackexchange.com/users/31788",
"pm_score": 3,
"selected": true,
"text": "<p>I think your first partial code be this partial code:</p>\n\n<pre><code>$wpdb->prepare( \"SELECT *... | 2013/09/09 | [
"https://wordpress.stackexchange.com/questions/113534",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28280/"
] | I want to execute a query like this:
```
$wpdb->prepare( "SELECT * ... from ... WHERE ( post_title LIKE '%%%s%%' or post_content LIKE '%%%s%%' )..., $string );
```
If I do the query with only one condition it works:
```
$wpdb->prepare( "SELECT * ... from ... WHERE ( post_title LIKE '%%%s%%' )..., $string );
```
W... | I think your first partial code be this partial code:
```
$wpdb->prepare( "SELECT * ... from ... WHERE ( post_title LIKE '%%%s%%' or post_content LIKE '%%%s%%' )..., $string, $string );
```
You have to have to pass the same number of arguments into the query as you specify (with %s) in it. |
113,568 | <p>WordPress is 404ing all of my Custom Post Type posts. Have I missed a step here?</p>
<p>I’m using the following to set up my CPT:</p>
<pre><code>function custom_post_types() {
register_post_type(
'creativework',
array(
'labels' => array(
'name' => _x('Works', 'post type general name... | [
{
"answer_id": 113569,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 0,
"selected": false,
"text": "<p>You have an error in the arguments of register_post_type that can be causing problems in the frontend. This a... | 2013/09/10 | [
"https://wordpress.stackexchange.com/questions/113568",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37816/"
] | WordPress is 404ing all of my Custom Post Type posts. Have I missed a step here?
I’m using the following to set up my CPT:
```
function custom_post_types() {
register_post_type(
'creativework',
array(
'labels' => array(
'name' => _x('Works', 'post type general name'),
'singular_name'... | Got it. I had tried to use `flush_rewrite_rules()` on plugin activation/deactivation, as so:
```
function creativeworks_activate() {
// register taxonomies/post types here
flush_rewrite_rules();
}
function creativeworks_deactivate() {
flush_rewrite_rules();
}
register_activation_hook( __FILE__, 'creativeworks_... |
113,585 | <p>I'm new to WooCommerce and I have the problem that grouped products always show the default VAT because I can't change the tax setting on the grouped products. The simple products combined by the grouped one have the reduced rate.</p>
<p>So I probably have to change the output in my (sub-)theme to the VAT of the fi... | [
{
"answer_id": 114018,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 2,
"selected": false,
"text": "<p><strong>code update:</strong></p>\n\n<pre><code>add_action( 'woocommerce_grouped_product_list_befor... | 2013/09/10 | [
"https://wordpress.stackexchange.com/questions/113585",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37826/"
] | I'm new to WooCommerce and I have the problem that grouped products always show the default VAT because I can't change the tax setting on the grouped products. The simple products combined by the grouped one have the reduced rate.
So I probably have to change the output in my (sub-)theme to the VAT of the first connec... | **code update:**
```
add_action( 'woocommerce_grouped_product_list_before_price',
'woocommerce_grouped_product_tax_on_single', 10, 1, $child_product, $mode );
function woocommerce_grouped_product_tax_on_single( $child_product, $mode = null ) {
//uncomment next line and choose one of the output options fr... |
113,586 | <p>I am using the popular Disqus plugin. To use this plugin effectively, they <a href="http://help.disqus.com/customer/portal/articles/565624-tightening-your-disqus-integration" rel="nofollow">advise</a> you to change the URL on the front page to end in <code>#disqus_thread</code>. I know how to easily do this in jQuer... | [
{
"answer_id": 114018,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 2,
"selected": false,
"text": "<p><strong>code update:</strong></p>\n\n<pre><code>add_action( 'woocommerce_grouped_product_list_befor... | 2013/09/10 | [
"https://wordpress.stackexchange.com/questions/113586",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16574/"
] | I am using the popular Disqus plugin. To use this plugin effectively, they [advise](http://help.disqus.com/customer/portal/articles/565624-tightening-your-disqus-integration) you to change the URL on the front page to end in `#disqus_thread`. I know how to easily do this in jQuery, but I figured it would be easier if I... | **code update:**
```
add_action( 'woocommerce_grouped_product_list_before_price',
'woocommerce_grouped_product_tax_on_single', 10, 1, $child_product, $mode );
function woocommerce_grouped_product_tax_on_single( $child_product, $mode = null ) {
//uncomment next line and choose one of the output options fr... |
113,588 | <p>I have a custom <code>wp_list_table</code> to create my own table. Almost everything works perfect, but the bulk action button seems to be not working. It's proper displayed,but on click nothing happens. I think somehow there is a form-wrapper missing or just some javascript? I added the button described on wp-engin... | [
{
"answer_id": 114018,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 2,
"selected": false,
"text": "<p><strong>code update:</strong></p>\n\n<pre><code>add_action( 'woocommerce_grouped_product_list_befor... | 2013/09/10 | [
"https://wordpress.stackexchange.com/questions/113588",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37828/"
] | I have a custom `wp_list_table` to create my own table. Almost everything works perfect, but the bulk action button seems to be not working. It's proper displayed,but on click nothing happens. I think somehow there is a form-wrapper missing or just some javascript? I added the button described on wp-engineeers: <http:/... | **code update:**
```
add_action( 'woocommerce_grouped_product_list_before_price',
'woocommerce_grouped_product_tax_on_single', 10, 1, $child_product, $mode );
function woocommerce_grouped_product_tax_on_single( $child_product, $mode = null ) {
//uncomment next line and choose one of the output options fr... |
113,595 | <p>I have googled a lot, but so far haven't come close to a proper solution yet. I need help with passing parameters to the homepage of a WordPress website. Here's my setup / requirements:</p>
<ol>
<li><p>I use a page template (say, MCTemplate) that is set as the static front page in Settings -> Reading.</p></li>
<li>... | [
{
"answer_id": 113625,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 3,
"selected": true,
"text": "<p><code>front-page.php</code> <strong>is</strong> a static front page (if you rename your current template <code... | 2013/09/10 | [
"https://wordpress.stackexchange.com/questions/113595",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3461/"
] | I have googled a lot, but so far haven't come close to a proper solution yet. I need help with passing parameters to the homepage of a WordPress website. Here's my setup / requirements:
1. I use a page template (say, MCTemplate) that is set as the static front page in Settings -> Reading.
2. I use 'Post name' permalin... | `front-page.php` **is** a static front page (if you rename your current template `front-page.php`, and don't select nothing in *Settings->Reading* it works exactly like now.
However, if you want to use the *page* approach and you **don't** use `mcdata` for query, remove the filter you posted, and simply retrieve the `... |
113,607 | <p>here is the commonly recommended sql command for removing posts revisions and cleaning up the wp database:</p>
<pre><code>DELETE a,b,c
FROM `wp_posts` a
LEFT JOIN `wp_term_relationships` b ON (a.ID = b.object_id)
LEFT JOIN `wp_postmeta` c ON (a.ID = c.post_id)
WHERE a.post_type = 'revision';
</code></pre>
<p>how c... | [
{
"answer_id": 113635,
"author": "Ben Miller - Remember Monica",
"author_id": 32110,
"author_profile": "https://wordpress.stackexchange.com/users/32110",
"pm_score": 2,
"selected": false,
"text": "<p>You can prevent more than three revisions from being saved to the database in the future... | 2013/09/10 | [
"https://wordpress.stackexchange.com/questions/113607",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25845/"
] | here is the commonly recommended sql command for removing posts revisions and cleaning up the wp database:
```
DELETE a,b,c
FROM `wp_posts` a
LEFT JOIN `wp_term_relationships` b ON (a.ID = b.object_id)
LEFT JOIN `wp_postmeta` c ON (a.ID = c.post_id)
WHERE a.post_type = 'revision';
```
how can i modify it to keep let... | You can prevent more than three revisions from being saved to the database in the future by adding this line to your `wp-config.php` file:
```
define( 'WP_POST_REVISIONS', 3 );
```
That line should limit new posts to three revisions, but it won't go through your database and clean it up.
The SQL snippet that you fo... |
113,608 | <p>I use Advanced Custom Fields and have a custompost-type "matches". This post-type contains two fields "goals-made" and "goals-against".</p>
<p>I want to query wordpress to show only the matches that were won. So where "goals made" > "goals-against".</p>
<p>Can anyone help me get started on this one. The goal is to... | [
{
"answer_id": 113620,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 2,
"selected": false,
"text": "<p>If I was in your situation, I'd used a different approach.</p>\n\n<p>Simply add an hidden meta field automati... | 2013/09/10 | [
"https://wordpress.stackexchange.com/questions/113608",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24096/"
] | I use Advanced Custom Fields and have a custompost-type "matches". This post-type contains two fields "goals-made" and "goals-against".
I want to query wordpress to show only the matches that were won. So where "goals made" > "goals-against".
Can anyone help me get started on this one. The goal is to have a statistic... | If I was in your situation, I'd used a different approach.
Simply add an hidden meta field automatically when goals\_made is updated.
E.g.
```
add_action('updated_postmeta', 'update_goal_made', 20, 4);
function update_goal_made( $meta_id, $object_id, $meta_key, $_meta_value ) {
if ( $meta_key != 'goals-made') ret... |
113,631 | <p>I've created a simple theme options page for my site. The options page contains three input fields. I can output the the fields by using get_option. </p>
<p>The three fields are called using the following:</p>
<pre><code><?php echo get_option( 'map_zoom' ); ?>
<?php echo get_option( 'map_longitude' ); ?&g... | [
{
"answer_id": 113620,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 2,
"selected": false,
"text": "<p>If I was in your situation, I'd used a different approach.</p>\n\n<p>Simply add an hidden meta field automati... | 2013/09/10 | [
"https://wordpress.stackexchange.com/questions/113631",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29158/"
] | I've created a simple theme options page for my site. The options page contains three input fields. I can output the the fields by using get\_option.
The three fields are called using the following:
```
<?php echo get_option( 'map_zoom' ); ?>
<?php echo get_option( 'map_longitude' ); ?>
<?php echo get_option( 'map_l... | If I was in your situation, I'd used a different approach.
Simply add an hidden meta field automatically when goals\_made is updated.
E.g.
```
add_action('updated_postmeta', 'update_goal_made', 20, 4);
function update_goal_made( $meta_id, $object_id, $meta_key, $_meta_value ) {
if ( $meta_key != 'goals-made') ret... |
113,662 | <p>I want to setcookie if is_page('arabic') or is_page('english') then redirect to home_url()
only if the page name/slug <code>arabic</code> or <code>english</code>, I think that init action happen before the code determine the current page, how to do that</p>
<p>Also after fixing that problem , how can I be sure that... | [
{
"answer_id": 113692,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 1,
"selected": false,
"text": "<p><code>template_redirect</code> and <code>wp</code> (as the OP noted in comments) are good hooks to do this.... | 2013/09/10 | [
"https://wordpress.stackexchange.com/questions/113662",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37854/"
] | I want to setcookie if is\_page('arabic') or is\_page('english') then redirect to home\_url()
only if the page name/slug `arabic` or `english`, I think that init action happen before the code determine the current page, how to do that
Also after fixing that problem , how can I be sure that setcookie will happen before... | `template_redirect` and `wp` (as the OP noted in comments) are good hooks to do this. But there's a problem of logic in the sample code. I think it should be like:
```
add_action( 'template_redirect', 'cookie_redirect_wpse_113662' );
function cookie_redirect_wpse_113662() {
# No cookie set, let's do it
if( !i... |
113,663 | <p>Hello i have created taxonomy in custom post type that act like category.</p>
<p>then i have created terms that acts like categories.</p>
<p>i have create widget that show all terms from taxonomy. all works great.</p>
<p>but i can"t understand how to limit the number of terms to show.</p>
<p>i have created input... | [
{
"answer_id": 113666,
"author": "Anjum",
"author_id": 3311,
"author_profile": "https://wordpress.stackexchange.com/users/3311",
"pm_score": 1,
"selected": false,
"text": "<p>change number value as required </p>\n\n<pre><code>$terms = get_terms('new_category', 'number=10');\necho '<ul... | 2013/09/10 | [
"https://wordpress.stackexchange.com/questions/113663",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36923/"
] | Hello i have created taxonomy in custom post type that act like category.
then i have created terms that acts like categories.
i have create widget that show all terms from taxonomy. all works great.
but i can"t understand how to limit the number of terms to show.
i have created input in my widget. so if i put some... | ```
number
(integer) The maximum number of terms to return. Default is to return them all.
http://codex.wordpress.org/Function_Reference/get_terms
```
So...
```
$terms = get_terms('new_category',array('number' => 5));
```
But there is a good chance that some of your terms will never show up. You will get th... |
113,675 | <p>Trying to set up custom schedules for WP Cron, knowing that they use an interval is it even possible to set up a cron job for every first of the month? As well as every fifteenth. This is what I have so far:</p>
<pre><code>private function cron_schedules( $schedules ) {
$midnight = strtotime( "midnight", curre... | [
{
"answer_id": 113690,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 4,
"selected": true,
"text": "<p><code>wp_cron</code> operates on intervals and there is no interval that will hit exactly the first day and t... | 2013/09/10 | [
"https://wordpress.stackexchange.com/questions/113675",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18241/"
] | Trying to set up custom schedules for WP Cron, knowing that they use an interval is it even possible to set up a cron job for every first of the month? As well as every fifteenth. This is what I have so far:
```
private function cron_schedules( $schedules ) {
$midnight = strtotime( "midnight", current_time( 'time... | `wp_cron` operates on intervals and there is no interval that will hit exactly the first day and the 15th of every month.
You could run your `wp-cron` job every day and check the date, [similar to this](https://wordpress.stackexchange.com/a/109438/21376) but with a simple callback like:
```
cron_callback_wpse_113675... |
113,691 | <p>Using this well written post - tutorial <a href="https://wordpress.stackexchange.com/questions/77308/edit-dashboards-help-tab/">Edit dashboard's help tab</a> I have full control over all standard WordPress admin screens.</p>
<p>Can this be modified to add "Help" Tabs to custom post types?</p>
| [
{
"answer_id": 113694,
"author": "Nat",
"author_id": 37870,
"author_profile": "https://wordpress.stackexchange.com/users/37870",
"pm_score": -1,
"selected": false,
"text": "<p>I actually happened to bump into this answer yesterday on this tutorial:</p>\n\n<ul>\n<li><a href=\"http://wp.sm... | 2013/09/11 | [
"https://wordpress.stackexchange.com/questions/113691",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37866/"
] | Using this well written post - tutorial [Edit dashboard's help tab](https://wordpress.stackexchange.com/questions/77308/edit-dashboards-help-tab/) I have full control over all standard WordPress admin screens.
Can this be modified to add "Help" Tabs to custom post types? | Use this code for solve your Problem.
```
function custom_help() {
global $post_ID;
$screen = get_current_screen();
if( isset($_GET['post_type']) ) $post_type = $_GET['post_type'];
else $post_type = get_post_type( $post_ID );
if( $post_type == 'listing' ) :
$screen->add_help_tab( array(
... |
113,695 | <p>This is the code I have currently on my development site. It only shows 10 results from custom post type "pacificheritage" but it should show 23 all together.</p>
<pre><code><?php
global $post;
$i=1;
$args = array(
'order' => 'ASC',
'o... | [
{
"answer_id": 113697,
"author": "Nat",
"author_id": 37870,
"author_profile": "https://wordpress.stackexchange.com/users/37870",
"pm_score": 4,
"selected": true,
"text": "<p>You need to add 'posts_per_page'=>'-1' to $args, so:</p>\n\n<pre><code><?php \n global $... | 2013/09/11 | [
"https://wordpress.stackexchange.com/questions/113695",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37394/"
] | This is the code I have currently on my development site. It only shows 10 results from custom post type "pacificheritage" but it should show 23 all together.
```
<?php
global $post;
$i=1;
$args = array(
'order' => 'ASC',
'orderby' => 'post_dat... | You need to add 'posts\_per\_page'=>'-1' to $args, so:
```
<?php
global $post;
$i=1;
$args = array(
'order' => 'ASC',
'orderby' => 'post_date',
'post_status' => 'publish',
'post_type' => 'pacificheritage',
'posts_per_page'=>'-1'
);... |
113,700 | <p>So many jQuery light boxes these days use the 'rel' attribute to identify objects that should be targeted. Unfortunately when it comes to Wordpress, when inserting a thumbnail/link, to add a rel attribute you have to either edit the html source code or pull up a separate pop-up after the initial insert. This makes t... | [
{
"answer_id": 113697,
"author": "Nat",
"author_id": 37870,
"author_profile": "https://wordpress.stackexchange.com/users/37870",
"pm_score": 4,
"selected": true,
"text": "<p>You need to add 'posts_per_page'=>'-1' to $args, so:</p>\n\n<pre><code><?php \n global $... | 2013/09/11 | [
"https://wordpress.stackexchange.com/questions/113700",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37218/"
] | So many jQuery light boxes these days use the 'rel' attribute to identify objects that should be targeted. Unfortunately when it comes to Wordpress, when inserting a thumbnail/link, to add a rel attribute you have to either edit the html source code or pull up a separate pop-up after the initial insert. This makes the ... | You need to add 'posts\_per\_page'=>'-1' to $args, so:
```
<?php
global $post;
$i=1;
$args = array(
'order' => 'ASC',
'orderby' => 'post_date',
'post_status' => 'publish',
'post_type' => 'pacificheritage',
'posts_per_page'=>'-1'
);... |
113,729 | <p>Hi I've been trying to figure this out for quite some time now, but whatever I do nothing seem to work.</p>
<p>I have a VPS setup running Nginx + Varnish with WordPress multisite.</p>
<p>Everything works fine except the admin/toolbar when browsing the sites. It simply wont load. It loads in the admin area, but whe... | [
{
"answer_id": 113697,
"author": "Nat",
"author_id": 37870,
"author_profile": "https://wordpress.stackexchange.com/users/37870",
"pm_score": 4,
"selected": true,
"text": "<p>You need to add 'posts_per_page'=>'-1' to $args, so:</p>\n\n<pre><code><?php \n global $... | 2013/09/11 | [
"https://wordpress.stackexchange.com/questions/113729",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37887/"
] | Hi I've been trying to figure this out for quite some time now, but whatever I do nothing seem to work.
I have a VPS setup running Nginx + Varnish with WordPress multisite.
Everything works fine except the admin/toolbar when browsing the sites. It simply wont load. It loads in the admin area, but when viewing site it... | You need to add 'posts\_per\_page'=>'-1' to $args, so:
```
<?php
global $post;
$i=1;
$args = array(
'order' => 'ASC',
'orderby' => 'post_date',
'post_status' => 'publish',
'post_type' => 'pacificheritage',
'posts_per_page'=>'-1'
);... |
113,762 | <p>I have been looking quite a long time for a way to stop people from posting external images in comments i e</p>
<pre><code><img alt="my photo" src="http://example.co.uk/pic.jpg" />
</code></pre>
<p>and the image is displayed, without permission from the owner. This is hard coded somewhere in core but I can't... | [
{
"answer_id": 113771,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": true,
"text": "<p>You can strip images on display pretty easily.</p>\n\n<pre><code>add_filter(\n 'comment_text',\n function($... | 2013/09/11 | [
"https://wordpress.stackexchange.com/questions/113762",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22724/"
] | I have been looking quite a long time for a way to stop people from posting external images in comments i e
```
<img alt="my photo" src="http://example.co.uk/pic.jpg" />
```
and the image is displayed, without permission from the owner. This is hard coded somewhere in core but I can't find a way to unset this behavi... | You can strip images on display pretty easily.
```
add_filter(
'comment_text',
function($comment) {
$allowed_html = array(
'a' => array(
'href' => array(),
'title' => array()
),
'br' => array(),
'em' => array(),
'strong' => array()
);
return wp_kses($com... |
113,763 | <p>I needed to assign categories to post from frontend so I am making use of the solution <a href="https://wordpress.stackexchange.com/questions/43419/how-do-i-create-a-way-for-users-to-assign-categories-to-a-post-from-the-frontend">suggested in this thread</a> , in form of a plugin. It is working as expected. I just w... | [
{
"answer_id": 113769,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 4,
"selected": true,
"text": "<p>You are not inserting the nonce field in your form, so your script won't recieve the nonce field and this code... | 2013/09/11 | [
"https://wordpress.stackexchange.com/questions/113763",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25508/"
] | I needed to assign categories to post from frontend so I am making use of the solution [suggested in this thread](https://wordpress.stackexchange.com/questions/43419/how-do-i-create-a-way-for-users-to-assign-categories-to-a-post-from-the-frontend) , in form of a plugin. It is working as expected. I just wanted to add a... | You are not inserting the nonce field in your form, so your script won't recieve the nonce field and this code:
```
if ( !isset($_POST['nonce_name']))
```
Will be validated becasue `$_POST['nonce_name']` is not set.
In your code, remove this line:
```
<input type='hidden' value='".wp_nonce_field('nonce_action','n... |
113,767 | <p>In the Admin Panel, is there a way to hook into the page creation and increment Page Order number of each page or to be equal to the number of pages. Right now the default is <code>0</code> and when I make a new page i would much rather have it at the bottom of my list than the top. </p>
| [
{
"answer_id": 113773,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>I am fairly sure that this will do what you want without having to mess with the \"Page Order\" value.</p>\n... | 2013/09/11 | [
"https://wordpress.stackexchange.com/questions/113767",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7355/"
] | In the Admin Panel, is there a way to hook into the page creation and increment Page Order number of each page or to be equal to the number of pages. Right now the default is `0` and when I make a new page i would much rather have it at the bottom of my list than the top. | The following is a possible solution, but needs some testing to confirm it is viable. It runs only if `menu_order == 0` and if it's not an auto-draft or revision being saved
```
add_action( 'save_post', 'incremental_save_wpse_113767', 10, 2 );
function incremental_save_wpse_113767( $post_id, $post_object )
{
if( ... |
113,772 | <p>I have a WordPress page with a grid that pull posts. Each post is in a box showing the title + thumbnail and upon clicking on it the content of the post should also appear in the modal (namely, pulling the data from the post which is clicked). </p>
<p>I have been looking at this example: <a href="https://wordpress.... | [
{
"answer_id": 113776,
"author": "murdaugh",
"author_id": 37908,
"author_profile": "https://wordpress.stackexchange.com/users/37908",
"pm_score": 1,
"selected": true,
"text": "<p>Since I'm guessing you're not rendering that Javascript file with PHP, you'll need to send the ID of the post... | 2013/09/11 | [
"https://wordpress.stackexchange.com/questions/113772",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35978/"
] | I have a WordPress page with a grid that pull posts. Each post is in a box showing the title + thumbnail and upon clicking on it the content of the post should also appear in the modal (namely, pulling the data from the post which is clicked).
I have been looking at this example: [Open WordPress Posts in Bootstrap Mo... | Since I'm guessing you're not rendering that Javascript file with PHP, you'll need to send the ID of the post to that anonymous function using something other than PHP. You could use a data attribute in your #clickme `<a>` like `data-id="<?php the_ID(); ?>"` and then change your on click to:
```
$(document).ready(fu... |
113,787 | <p>I am using custom structure for permalink: <code>/%postname%/%page%/%year%/</code>. </p>
<p>When I navigate to <code>http://wordpress-serv/projects-teams/designers/19/2013</code>, it gives me 404 "Page not found". </p>
<p>Nonetheless, it is working fine with <code>http://wordpress-serv/projects-teams/designers/19<... | [
{
"answer_id": 113776,
"author": "murdaugh",
"author_id": 37908,
"author_profile": "https://wordpress.stackexchange.com/users/37908",
"pm_score": 1,
"selected": true,
"text": "<p>Since I'm guessing you're not rendering that Javascript file with PHP, you'll need to send the ID of the post... | 2013/09/11 | [
"https://wordpress.stackexchange.com/questions/113787",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37912/"
] | I am using custom structure for permalink: `/%postname%/%page%/%year%/`.
When I navigate to `http://wordpress-serv/projects-teams/designers/19/2013`, it gives me 404 "Page not found".
Nonetheless, it is working fine with `http://wordpress-serv/projects-teams/designers/19` (without year) and `get_query_var('page');`... | Since I'm guessing you're not rendering that Javascript file with PHP, you'll need to send the ID of the post to that anonymous function using something other than PHP. You could use a data attribute in your #clickme `<a>` like `data-id="<?php the_ID(); ?>"` and then change your on click to:
```
$(document).ready(fu... |
113,792 | <p>I'm using WP v3.6 and v2.6 of the plugin and using inline lightboxes to open a YouTube video embeded with an iframe. My boss wants the video to play when the lightbox opens. So originally I tried:</p>
<pre><code>var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScr... | [
{
"answer_id": 113776,
"author": "murdaugh",
"author_id": 37908,
"author_profile": "https://wordpress.stackexchange.com/users/37908",
"pm_score": 1,
"selected": true,
"text": "<p>Since I'm guessing you're not rendering that Javascript file with PHP, you'll need to send the ID of the post... | 2013/09/11 | [
"https://wordpress.stackexchange.com/questions/113792",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33447/"
] | I'm using WP v3.6 and v2.6 of the plugin and using inline lightboxes to open a YouTube video embeded with an iframe. My boss wants the video to play when the lightbox opens. So originally I tried:
```
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = docum... | Since I'm guessing you're not rendering that Javascript file with PHP, you'll need to send the ID of the post to that anonymous function using something other than PHP. You could use a data attribute in your #clickme `<a>` like `data-id="<?php the_ID(); ?>"` and then change your on click to:
```
$(document).ready(fu... |
113,808 | <p>I am building a site with 4 custom post types.
To make things easier for our client/admin, I'm wondering if there is a way to merge those custom post types into one list in the backend? Like if you look at normal backend admin page with the list and columns of posts, can a page like that pull in 3 other post types f... | [
{
"answer_id": 114215,
"author": "Alex V.",
"author_id": 20910,
"author_profile": "https://wordpress.stackexchange.com/users/20910",
"pm_score": 1,
"selected": false,
"text": "<p>I'd recommend Admin Menu Editor pro for this. I'll link to it at the bottom.</p>\n\n<p>Interesting. On a cert... | 2013/09/11 | [
"https://wordpress.stackexchange.com/questions/113808",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36436/"
] | I am building a site with 4 custom post types.
To make things easier for our client/admin, I'm wondering if there is a way to merge those custom post types into one list in the backend? Like if you look at normal backend admin page with the list and columns of posts, can a page like that pull in 3 other post types for ... | Just a starting point, as surely issues will popup during further development. For example, right now, the search functionality breaks as it expects a string (post\_type) and it's receiving an array.
To list more than one post type in the Posts screen, we hook into `pre_get_posts` and modify the query. In this test, P... |
113,813 | <p>I am using option tree. In textarea, i place shortcode</p>
<pre><code>[layerslider id="1"]
</code></pre>
<p>its not working, i also found same post replied by plugin author
<a href="http://wordpress.org/support/topic/plugin-optiontree-allow-shortcodes-in-textarea" rel="nofollow">allow shortcodes in textarea in op... | [
{
"answer_id": 114215,
"author": "Alex V.",
"author_id": 20910,
"author_profile": "https://wordpress.stackexchange.com/users/20910",
"pm_score": 1,
"selected": false,
"text": "<p>I'd recommend Admin Menu Editor pro for this. I'll link to it at the bottom.</p>\n\n<p>Interesting. On a cert... | 2013/09/11 | [
"https://wordpress.stackexchange.com/questions/113813",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27001/"
] | I am using option tree. In textarea, i place shortcode
```
[layerslider id="1"]
```
its not working, i also found same post replied by plugin author
[allow shortcodes in textarea in option tree](http://wordpress.org/support/topic/plugin-optiontree-allow-shortcodes-in-textarea)
applied the
```
do_shortcode('[laye... | Just a starting point, as surely issues will popup during further development. For example, right now, the search functionality breaks as it expects a string (post\_type) and it's receiving an array.
To list more than one post type in the Posts screen, we hook into `pre_get_posts` and modify the query. In this test, P... |
113,815 | <p>I m trying to randomize several posts on my client's site which are on different pages , everyday. So I wrote a function which returns true on date change, and if does, I randomize the post ids and save them into the database and use the same values throughout the day, So here is what I m doing,</p>
<pre><code>func... | [
{
"answer_id": 114215,
"author": "Alex V.",
"author_id": 20910,
"author_profile": "https://wordpress.stackexchange.com/users/20910",
"pm_score": 1,
"selected": false,
"text": "<p>I'd recommend Admin Menu Editor pro for this. I'll link to it at the bottom.</p>\n\n<p>Interesting. On a cert... | 2013/09/11 | [
"https://wordpress.stackexchange.com/questions/113815",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34490/"
] | I m trying to randomize several posts on my client's site which are on different pages , everyday. So I wrote a function which returns true on date change, and if does, I randomize the post ids and save them into the database and use the same values throughout the day, So here is what I m doing,
```
function comi_date... | Just a starting point, as surely issues will popup during further development. For example, right now, the search functionality breaks as it expects a string (post\_type) and it's receiving an array.
To list more than one post type in the Posts screen, we hook into `pre_get_posts` and modify the query. In this test, P... |
113,820 | <p>I'm trying to create a shortcode that will search within some specified text for a link and replace it with one that I specify. For example:</p>
<pre><code>[scode]Click on <a href="www.X.com">this link</a>[scode]
[scode]Click on <a href="www.Y.com">this link</a>[scode]
</code></pre>
<p>...w... | [
{
"answer_id": 113833,
"author": "pixeline",
"author_id": 82,
"author_profile": "https://wordpress.stackexchange.com/users/82",
"pm_score": 0,
"selected": false,
"text": "<p>Try this:</p>\n\n<pre><code>function timMcLure_hide_text( $atts,$content=\"\") {\n if (!is_user_logged_in () ) ... | 2013/09/11 | [
"https://wordpress.stackexchange.com/questions/113820",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36167/"
] | I'm trying to create a shortcode that will search within some specified text for a link and replace it with one that I specify. For example:
```
[scode]Click on <a href="www.X.com">this link</a>[scode]
[scode]Click on <a href="www.Y.com">this link</a>[scode]
```
...will both be changed to:
```
[scode]Click on <a hr... | Your shortcode function should look like this:
```
function replace_url_for_nonlogged( $atts, $content = "") {
if ( is_user_logged_in () ) return $content;
extract( shortcode_atts( array(
'replace' => 'http://www.default_replace_url.com',
), $atts ) );
$pattern = '/href=("|\')((([A-Za-z]{3,9}:(?:\/\/)?)(?:... |
113,823 | <p>I get the following error whenever a user tries to request a password reset email:</p>
<pre><code>The e-mail could not be sent.
Possible reason: your host may have disabled the mail() function.
</code></pre>
<p>As per recommendations I've read across the web, I tried several SMTP plugins. None worked. Finally, I... | [
{
"answer_id": 114177,
"author": "Joshua",
"author_id": 7105,
"author_profile": "https://wordpress.stackexchange.com/users/7105",
"pm_score": 3,
"selected": true,
"text": "<p>Sounds like a server configuration problem, not a WordPress thing. You said you were using Rackspace? I don't hav... | 2013/09/11 | [
"https://wordpress.stackexchange.com/questions/113823",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5861/"
] | I get the following error whenever a user tries to request a password reset email:
```
The e-mail could not be sent.
Possible reason: your host may have disabled the mail() function.
```
As per recommendations I've read across the web, I tried several SMTP plugins. None worked. Finally, I got some debug information ... | Sounds like a server configuration problem, not a WordPress thing. You said you were using Rackspace? I don't have personal experience with Rackspace but it appears that they have some known issues with the default PHP `mail()` function. See:
1. <http://feedback.rackspace.com/forums/71021-product-feedback/suggestions... |
113,838 | <p>I have added a custom action hook into my theme. I want to be able to enter a shortcode anywhere in the_content() and have the shortcode print were the custom action hook is rather then the point from where the shortcode was entered.</p>
<p>The shortcode displays a gallery and the custom hook in the header.</p>
<p... | [
{
"answer_id": 113842,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": true,
"text": "<p>I think I'd use a meta box:</p>\n\n<pre><code>// create the meta box\nfunction dht_box() {\n add_meta_box(... | 2013/09/11 | [
"https://wordpress.stackexchange.com/questions/113838",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16641/"
] | I have added a custom action hook into my theme. I want to be able to enter a shortcode anywhere in the\_content() and have the shortcode print were the custom action hook is rather then the point from where the shortcode was entered.
The shortcode displays a gallery and the custom hook in the header.
It works if I d... | I think I'd use a meta box:
```
// create the meta box
function dht_box() {
add_meta_box(
'dht_box', // id, used as the html id att
__( 'Do Header Thing' ), // meta box title
'dht_cb', // callback function, spits out the content
'post' // post type or page. This adds to posts only
... |
113,843 | <p>In my theme I use <code>locate_template()</code> to load the various parts of my functions library. I'm looking for a way to not include one of those files when using a child theme. I tried adding <code>locate_template('same_file_name.php', false);</code> to my child theme's functions.php but it is still included.</... | [
{
"answer_id": 113844,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 0,
"selected": false,
"text": "<p>You could wrap the <code>locate_template</code> call in a check for <a href=\"http://codex.wordpress.org/Function_... | 2013/09/11 | [
"https://wordpress.stackexchange.com/questions/113843",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25300/"
] | In my theme I use `locate_template()` to load the various parts of my functions library. I'm looking for a way to not include one of those files when using a child theme. I tried adding `locate_template('same_file_name.php', false);` to my child theme's functions.php but it is still included.
CLARIFICATION EDIT: I don... | An alternative solution that takes inspiration from both answers by **@Milo** and **@toscho**.
create your own function to load template, e.g.
```
if ( ! function_exists('my_locate_template') ) {
function my_locate_template( $template = '', $load = false, $once = true ) {
$filtered = apply_filters('allow_child_... |
113,858 | <p>I want to create custom links like</p>
<p><code>mydomain.com/custom_page/cat=ABC&tag=XYZ</code></p>
<p>So that when a user clicks on the link s/he can see all posts in the category 'ABC' having tag 'XYZ'</p>
<p>For this I've created a custom template with the following code</p>
<pre><code><?php
/*
Templat... | [
{
"answer_id": 113844,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 0,
"selected": false,
"text": "<p>You could wrap the <code>locate_template</code> call in a check for <a href=\"http://codex.wordpress.org/Function_... | 2013/09/12 | [
"https://wordpress.stackexchange.com/questions/113858",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37937/"
] | I want to create custom links like
`mydomain.com/custom_page/cat=ABC&tag=XYZ`
So that when a user clicks on the link s/he can see all posts in the category 'ABC' having tag 'XYZ'
For this I've created a custom template with the following code
```
<?php
/*
Template Name: MyCustomTemplate
*/
?>
<?php get_header(); ?... | An alternative solution that takes inspiration from both answers by **@Milo** and **@toscho**.
create your own function to load template, e.g.
```
if ( ! function_exists('my_locate_template') ) {
function my_locate_template( $template = '', $load = false, $once = true ) {
$filtered = apply_filters('allow_child_... |
113,872 | <p>Is it possible to have separate archive templates for custom taxonomies?</p>
<p>Like this:</p>
<p>Tax(categories)</p>
<p>-Players(category)</p>
<p>-Managers(category)</p>
| [
{
"answer_id": 114207,
"author": "Charles Clarkson",
"author_id": 31788,
"author_profile": "https://wordpress.stackexchange.com/users/31788",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>Is it possible to have separate archive templates for custom taxonomies?</p>\n</bloc... | 2013/09/12 | [
"https://wordpress.stackexchange.com/questions/113872",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34210/"
] | Is it possible to have separate archive templates for custom taxonomies?
Like this:
Tax(categories)
-Players(category)
-Managers(category) | Yes, the heirarchy is like this:
```
taxonomy-{taxonomy}-{term}.php
taxonomy-{taxonomy}.php
taxonomy.php
archive.php
index.php
```
So in your case you would create:
taxonomy-tax-players.php
and
taxonomy-tax-managers.php |
113,873 | <p>I've searched a lot for this and I seem to get different answers.</p>
<p>In my situation, my jQuery function has to use a PHP variable from a different file.</p>
<p>How can I accomplish this? Clear and simple answer would be greatly appreciated.</p>
| [
{
"answer_id": 113876,
"author": "ferenyl",
"author_id": 11034,
"author_profile": "https://wordpress.stackexchange.com/users/11034",
"pm_score": 0,
"selected": false,
"text": "<p>You could use ajax to get the value from a function read about it here: <a href=\"http://codex.wordpress.org/... | 2013/09/12 | [
"https://wordpress.stackexchange.com/questions/113873",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36675/"
] | I've searched a lot for this and I seem to get different answers.
In my situation, my jQuery function has to use a PHP variable from a different file.
How can I accomplish this? Clear and simple answer would be greatly appreciated. | In general, this function lets you localize your JS strings, but you can also use it to set global JS variables:
```
function set_my_js_var() {
// logic here for returning the right JS var
$myVar = "Hello World";
return $myVar;
}
function load_fe_scripts() {
wp_enqueue_script( 'global-js-var', get_temp... |
113,877 | <p>While tweaking the "Bryans Childpage Thumbnail Generator" plugin, I am applying filter (with pagination) to the get_posts for WP Pages (<code>post_type=page</code>), but its not filtering at all. Here is the code:</p>
<pre><code>extract(shortcode_atts(array(
'order' => 'ASC',
'orderby' => 'tit... | [
{
"answer_id": 113880,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 0,
"selected": false,
"text": "<p>It looks like this condition is never fullfilled:</p>\n\n<pre><code>if($filter_year > 0)\n</code></pre>\n\... | 2013/09/12 | [
"https://wordpress.stackexchange.com/questions/113877",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37912/"
] | While tweaking the "Bryans Childpage Thumbnail Generator" plugin, I am applying filter (with pagination) to the get\_posts for WP Pages (`post_type=page`), but its not filtering at all. Here is the code:
```
extract(shortcode_atts(array(
'order' => 'ASC',
'orderby' => 'title',
'id' => '',
... | According with Wordpress documentation, the [post\_where filter](http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_where) will not affect to the query generated by the `get_posts()` function. See also the [default usage of get\_posts()](http://codex.wordpress.org/Function_Reference/get_posts#Default_Usage) w... |
113,879 | <p>Is there any plugin that can update the wordpress database, specifically the wp_posts table or any other custom table in the database created by other plugins which has absolute url's of images and other assets?</p>
<p>So for example I have an image in a post:</p>
<pre><code><img src="http://old-domain.com/wp-... | [
{
"answer_id": 113883,
"author": "user1514045",
"author_id": 37687,
"author_profile": "https://wordpress.stackexchange.com/users/37687",
"pm_score": 0,
"selected": false,
"text": "<p>I had much success using <a href=\"https://github.com/interconnectit/Search-Replace-DB\" rel=\"nofollow\"... | 2013/09/12 | [
"https://wordpress.stackexchange.com/questions/113879",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27291/"
] | Is there any plugin that can update the wordpress database, specifically the wp\_posts table or any other custom table in the database created by other plugins which has absolute url's of images and other assets?
So for example I have an image in a post:
```
<img src="http://old-domain.com/wp-content/uploads/images/i... | I had much success using <https://github.com/interconnectit/Search-Replace-DB>
Though there are Plugins for WordPress available that do a Search & Replace, i recommend the above linked script.
In older WordPress versions it was possible to move an entire site by simply replacing some strings, but as far as i know, Wo... |
113,907 | <p>How can I add a Wordpress user that can't be deleted (at all cost, not even by a superadmin) with some code? I can't find anything on Google about such a <em>god-account</em>.</p>
<p>This morning a client of our company deleted the main-admin account and deleted all of the websites content. We were able to restore ... | [
{
"answer_id": 113910,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>There doesn't seem to be a way to interrupt deletion process in <code>wp_delete_user()</code> function, which perfo... | 2013/09/12 | [
"https://wordpress.stackexchange.com/questions/113907",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36341/"
] | How can I add a Wordpress user that can't be deleted (at all cost, not even by a superadmin) with some code? I can't find anything on Google about such a *god-account*.
This morning a client of our company deleted the main-admin account and deleted all of the websites content. We were able to restore the website with ... | While you can't guarantee the absolute safety of this user, I have used this to *hide* my backdoor user (useful for clients who are aggressive in removing users, yet may forget to pay their bill, for example)
```
add_action('pre_user_query','sleeper_pre_user_query');
function sleeper_pre_user_query($user_search) {
... |
113,914 | <p>I'm looking for a snippit/function that will list the child pages of a specific page (I guess by page ID) but not necessarily when you are on that page or a child of that page. The parent page (Parents Area) and its child pages are listed below:</p>
<pre><code>Parents Area
- Term Dates
- Calendar
- School Blog
- Le... | [
{
"answer_id": 114050,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p>To list subpages of a particular page, use <a href=\"http://codex.wordpress.org/Function_Reference/wp_list_pages\" ... | 2013/09/12 | [
"https://wordpress.stackexchange.com/questions/113914",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36920/"
] | I'm looking for a snippit/function that will list the child pages of a specific page (I guess by page ID) but not necessarily when you are on that page or a child of that page. The parent page (Parents Area) and its child pages are listed below:
```
Parents Area
- Term Dates
- Calendar
- School Blog
- Letters to Paren... | To list subpages of a particular page, use [`wp_list_pages`](http://codex.wordpress.org/Function_Reference/wp_list_pages) with `child_of` argument.
```
$parent_page_id = 42;
wp_list_pages( array(
'child_of' => $parent_page_id
) );
``` |
113,935 | <p>I have a series of input fields sets:</p>
<pre><code><input type="text" name="people[name]" />
<input type="text" name="people[lastname]" />
<input type="text" name="people[email]" />
<input type="text" name="people[name]" />
<input type="text" name="people[lastname]" />
<input typ... | [
{
"answer_id": 113938,
"author": "Anjum",
"author_id": 3311,
"author_profile": "https://wordpress.stackexchange.com/users/3311",
"pm_score": 0,
"selected": false,
"text": "<p>create an array from your form fields <code>$_POST['people']</code> data use foreach loop to get and create array... | 2013/09/12 | [
"https://wordpress.stackexchange.com/questions/113935",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37160/"
] | I have a series of input fields sets:
```
<input type="text" name="people[name]" />
<input type="text" name="people[lastname]" />
<input type="text" name="people[email]" />
<input type="text" name="people[name]" />
<input type="text" name="people[lastname]" />
<input type="text" name="people[email]" />
...
```
and... | If two fields are named `people[name]`, only the last value will be sent with the form. To be completely reliable, you'll need to use an id for each person you're collecting details on:
```
<input name="people[0][name]">
<input name="people[0][email]">
<input name="people[1][name]">
<input name="people[1][email]">
...... |
113,936 | <p>I am using a 3rd party service that does a scrub of my database for new entries within a specific table. However I am been unable to find a simple form plugin that submits data to the wordpress database inside of a table that won't affect any of the wordpress functionality. The reason is my hosting provider only all... | [
{
"answer_id": 113943,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 3,
"selected": false,
"text": "<p>For what I can understand you already have the table in your database.</p>\n\n<p>I don't know how you have na... | 2013/09/12 | [
"https://wordpress.stackexchange.com/questions/113936",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15412/"
] | I am using a 3rd party service that does a scrub of my database for new entries within a specific table. However I am been unable to find a simple form plugin that submits data to the wordpress database inside of a table that won't affect any of the wordpress functionality. The reason is my hosting provider only allows... | For what I can understand you already have the table in your database.
I don't know how you have named it, but a best practise (for me a must-do practise) is to name it with the same table prefix of wordpress, that's the one setted in `wp-config.php`.
You also don't say how this table is structured, but I guess it's ... |
114,008 | <p>I have this code to show subpages in everypage. </p>
<pre><code><?php $parent = $post->ID; ?>
<?php query_posts('posts_per_page=15&post_type=page&post_parent='.$parent);
while (have_posts()) : the_post();
?>
<?php $image_thumb = get_post_meta($post->ID, 'image-thumb', true); ?>
&... | [
{
"answer_id": 113997,
"author": "ahmetlutfu",
"author_id": 25086,
"author_profile": "https://wordpress.stackexchange.com/users/25086",
"pm_score": 1,
"selected": true,
"text": "<p>You must use cache systems.without caching, your site will be slowly.use APC or memcache for increase speed... | 2013/09/13 | [
"https://wordpress.stackexchange.com/questions/114008",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37998/"
] | I have this code to show subpages in everypage.
```
<?php $parent = $post->ID; ?>
<?php query_posts('posts_per_page=15&post_type=page&post_parent='.$parent);
while (have_posts()) : the_post();
?>
<?php $image_thumb = get_post_meta($post->ID, 'image-thumb', true); ?>
<div class="subpages">
<h2><a href="<?php the_p... | You must use cache systems.without caching, your site will be slowly.use APC or memcache for increase speed of your home page.
or use [redis](http://www.jimwestergren.com/wordpress-with-maximum-performance-and-speed/). |
114,043 | <p>Around a fifth of post submissions that I receive contains ridiculous amounts of hidden formatting. </p>
<p>For example, here is some of it from a recent post:</p>
<pre><code><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMo... | [
{
"answer_id": 114045,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>I am interpreting the question to mean that you already have Word markup in your post and so you need to clea... | 2013/09/13 | [
"https://wordpress.stackexchange.com/questions/114043",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24875/"
] | Around a fifth of post submissions that I receive contains ridiculous amounts of hidden formatting.
For example, here is some of it from a recent post:
```
<!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgai... | I am interpreting the question to mean that you already have Word markup in your post and so you need to clean that up via PHP. If so...
1. You can see the code that cleans up Word content here:
<http://core.trac.wordpress.org/browser/trunk/src/wp-includes/js/tinymce/plugins/paste/editor_plugin_src.js#L375>
That is Ja... |
114,055 | <p>I have a custom post type called 'software', contained within are various custom fields such as subtitle, price, screenshots, download link, etc. I created a function to allow use of the tinyMCE edit window for some of these custom fields. I have been trying to display these fields on the page but with no success.</... | [
{
"answer_id": 114057,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 6,
"selected": true,
"text": "<p>Well, you are using:</p>\n\n<pre><code>get_post_meta(get_the_ID(), 'subtitle', TRUE);\n</code></pre>\n\n<p>So,... | 2013/09/13 | [
"https://wordpress.stackexchange.com/questions/114055",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37769/"
] | I have a custom post type called 'software', contained within are various custom fields such as subtitle, price, screenshots, download link, etc. I created a function to allow use of the tinyMCE edit window for some of these custom fields. I have been trying to display these fields on the page but with no success.
The... | Well, you are using:
```
get_post_meta(get_the_ID(), 'subtitle', TRUE);
```
So, you are saying to Wordpress to get the meta value of the 'subtitle' field and that the returned value be in format of string. See [get\_post\_meta() docu](http://codex.wordpress.org/Function_Reference/get_post_meta).
To get all meta dat... |
114,074 | <p>I'm using twenty twelve and I need to insert a div between the posts. I'm not sure how to stop the loop, insert the div, and then restart the loop.</p>
<p>Can anyone shed some light on this? Thanks.</p>
| [
{
"answer_id": 114081,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p>You can check your position within the loop using the <code>current_post</code> var of the <code>$wp_query</code> o... | 2013/09/13 | [
"https://wordpress.stackexchange.com/questions/114074",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37978/"
] | I'm using twenty twelve and I need to insert a div between the posts. I'm not sure how to stop the loop, insert the div, and then restart the loop.
Can anyone shed some light on this? Thanks. | You can check your position within the loop using the `current_post` var of the `$wp_query` object, and insert markup at a specific spot or at some interval. A simple example:
```
while( have_posts() ):
the_post();
the_title();
the_excerpt();
// if current_post is 1, insert the div
// note that c... |
114,087 | <p>This is the php I have for a form which creates a post with thumbnail. I want to know how to add the uploaded image to the post content as well. Tried a few things, but they didn't work. </p>
<pre><code> if(isset($_POST['new_post']) == '1') {
$post_title = $_POST['post_title'];
$post_category = $_P... | [
{
"answer_id": 114081,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p>You can check your position within the loop using the <code>current_post</code> var of the <code>$wp_query</code> o... | 2013/09/13 | [
"https://wordpress.stackexchange.com/questions/114087",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9869/"
] | This is the php I have for a form which creates a post with thumbnail. I want to know how to add the uploaded image to the post content as well. Tried a few things, but they didn't work.
```
if(isset($_POST['new_post']) == '1') {
$post_title = $_POST['post_title'];
$post_category = $_POST['cat'];
... | You can check your position within the loop using the `current_post` var of the `$wp_query` object, and insert markup at a specific spot or at some interval. A simple example:
```
while( have_posts() ):
the_post();
the_title();
the_excerpt();
// if current_post is 1, insert the div
// note that c... |
114,095 | <p>In my jquery script I have;</p>
<pre><code>jQuery.ajax(
ajaxurl, {
action: 'lu_ajax',
status: 'enabled'
},
success: function (a) {
alert(a)
}
</code></pre>
<p>In my file.php i have;</p>
<pre><code>add_action('wp_ajax_lu_ajax', 'lu_ajax');
add_action('wp_ajax... | [
{
"answer_id": 114098,
"author": "david.binda",
"author_id": 14022,
"author_profile": "https://wordpress.stackexchange.com/users/14022",
"pm_score": 1,
"selected": false,
"text": "<p>ajaxurl is set only in admin. If this is a frontend ajax (looks like it due to nopriv), you have to local... | 2013/09/13 | [
"https://wordpress.stackexchange.com/questions/114095",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17284/"
] | In my jquery script I have;
```
jQuery.ajax(
ajaxurl, {
action: 'lu_ajax',
status: 'enabled'
},
success: function (a) {
alert(a)
}
```
In my file.php i have;
```
add_action('wp_ajax_lu_ajax', 'lu_ajax');
add_action('wp_ajax_nopriv_lu_ajax', 'lu_ajax'); //for l... | First of all, your js is wrong, you are mixing the syntax of `jQuery.post()` and of `jQuery.ajax()`
You should use
```
jQuery.ajax({
type: "POST",
url: ajaxurl,
data: { action: "lu_ajax", status: "enabled" },
success: function( data ) {
alert(data);
}
});
```
or
```
jQuery.post(
ajaxurl,
{ action... |
114,107 | <p>I'm trying to make pop up in admin area (in post edit screen) and i can't make my thickbox wider then 670px (width: 670px).</p>
<p>Here's my thickbox code that shows thickbox:</p>
<pre><code>tb_show( ed.getLang('m7.popup_title'), '#TB_inline?width=800&height=600&inlineId=mygallery-form' );
</code></pre>
<... | [
{
"answer_id": 137286,
"author": "Ryan Bayne",
"author_id": 35010,
"author_profile": "https://wordpress.stackexchange.com/users/35010",
"pm_score": 1,
"selected": false,
"text": "<p>Your are correct it cannot be changed and it looks like there has been no change on this since your questi... | 2013/09/13 | [
"https://wordpress.stackexchange.com/questions/114107",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38034/"
] | I'm trying to make pop up in admin area (in post edit screen) and i can't make my thickbox wider then 670px (width: 670px).
Here's my thickbox code that shows thickbox:
```
tb_show( ed.getLang('m7.popup_title'), '#TB_inline?width=800&height=600&inlineId=mygallery-form' );
```
(it works after clicking the tinyMCE bu... | From the comment under my question ( may be someone could miss it, so posting it as an answer )[PS: slightly modifyed it]:
I think i found a solution how to change the width, but that's not the real solution.. I still don't get it why thickbox width is 670px (as u can see in my code (will follow next) the global thick... |
114,110 | <p>We want to create a short-code. The final output of the source code should be similar to the code mentioned below.</p>
<pre><code><script type="text/javascript" src="http://hosted.musesradioplayer.com/mrp.js"></script>
<script type="text/javascript">
MRP.insert({
'url':'http://streams.museter.com:... | [
{
"answer_id": 114113,
"author": "Daniel",
"author_id": 9060,
"author_profile": "https://wordpress.stackexchange.com/users/9060",
"pm_score": 1,
"selected": false,
"text": "<p>WordPress offers a function called <a href=\"http://codex.wordpress.org/Function_Reference/wp_localize_script\" ... | 2013/09/14 | [
"https://wordpress.stackexchange.com/questions/114110",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38036/"
] | We want to create a short-code. The final output of the source code should be similar to the code mentioned below.
```
<script type="text/javascript" src="http://hosted.musesradioplayer.com/mrp.js"></script>
<script type="text/javascript">
MRP.insert({
'url':'http://streams.museter.com:8002/;',
'codec':'mp3',
'volume'... | WordPress offers a function called [wp\_localize\_script](http://codex.wordpress.org/Function_Reference/wp_localize_script). That function is your best friend for situations like yours. There are plenty of examples here. But I leave you with this good tutorial:
<http://pippinsplugins.com/use-wp_localize_script-it-is-a... |
114,111 | <p>Most solutions I found are for front-end use. This is for a plugin, so the all activity is in the back-end.</p>
<p>How do I get the page ID that's being currently use(edited) in the admin?</p>
<p><strong>Note</strong> I'm out of the loop. I just need to get the ID of page(not posts) that I'm currently seeing in th... | [
{
"answer_id": 114114,
"author": "Bindiya Patoliya",
"author_id": 34932,
"author_profile": "https://wordpress.stackexchange.com/users/34932",
"pm_score": 2,
"selected": false,
"text": "<p>You can add this code in functions.php file and it will give you a meta box above the publish settin... | 2013/09/14 | [
"https://wordpress.stackexchange.com/questions/114111",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9060/"
] | Most solutions I found are for front-end use. This is for a plugin, so the all activity is in the back-end.
How do I get the page ID that's being currently use(edited) in the admin?
**Note** I'm out of the loop. I just need to get the ID of page(not posts) that I'm currently seeing in the back-end. | You can also use
```
$post_id = $_GET['post'];
```
Or you can use a hook (probably better).
```
function id_WPSE_114111() {
global $post;
$id = $post->ID;
// do something
}
add_action( 'admin_notices', 'id_WPSE_114111' );
```
You will need to add a conditional since this will run on all admin pages, ... |
114,130 | <p>In order to optimize my site for a bit more loading speed, I wanted to enqueue a couple of scripts only to the archives for default post type. A rough example is given below.</p>
<pre><code>function my_theme_script_enqueues() {
if (!is_admin()) {
if ( is_archive()) {
wp_registe... | [
{
"answer_id": 114131,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 4,
"selected": true,
"text": "<p><code>is_archive()</code> doesn't accept any parameter and return true for every archive page: Categories, tag... | 2013/09/14 | [
"https://wordpress.stackexchange.com/questions/114130",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25508/"
] | In order to optimize my site for a bit more loading speed, I wanted to enqueue a couple of scripts only to the archives for default post type. A rough example is given below.
```
function my_theme_script_enqueues() {
if (!is_admin()) {
if ( is_archive()) {
wp_register_script('isot... | `is_archive()` doesn't accept any parameter and return true for every archive page: Categories, tag, date, author, .... I think what you need is to check if you are in a [category page](http://codex.wordpress.org/Function_Reference/is_category) (in a archive of the category taxonomy) or in the blog home:
```
if ( is_c... |
114,158 | <p>I'm trying to add a "Click here to edit this page" button in some Wordpress pages.</p>
<p>This button should only appear if the user is admin, this is the code that should appear if the user is admin:</p>
<pre><code>if ( current_user_can( 'manage_options' ) ) {
<div class="action">
<div class="pe-contain... | [
{
"answer_id": 114162,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>WordPress does not allow PHP code in content. While there are some solutions to circumvent that, it's typically bad... | 2013/09/14 | [
"https://wordpress.stackexchange.com/questions/114158",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27278/"
] | I'm trying to add a "Click here to edit this page" button in some Wordpress pages.
This button should only appear if the user is admin, this is the code that should appear if the user is admin:
```
if ( current_user_can( 'manage_options' ) ) {
<div class="action">
<div class="pe-container"><section class="row-fluid"... | As @Rarst said, use PHP code inside a post content is bad habit. But you can use another workaround to show a section only for appropriate users.
Add the following code into your `functions.php` file:
```
add_shortcode( 'if_user_can', 'wpse8170_show_content_if_user_can' );
function wpse8170_show_content_if_user_can( ... |
114,167 | <p>Desired behavior:
<code>http://www.situationware.com</code> should stay at <code>www.situationware.com</code>, no registration required.</p>
<p>Currently wordpress is automatically redirecting to the Amazon hostname <code>ec2-107-22-241-162.compute-1.amazonaws.com</code>, requesting users register, if I update wp-... | [
{
"answer_id": 114162,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>WordPress does not allow PHP code in content. While there are some solutions to circumvent that, it's typically bad... | 2013/09/14 | [
"https://wordpress.stackexchange.com/questions/114167",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38056/"
] | Desired behavior:
`http://www.situationware.com` should stay at `www.situationware.com`, no registration required.
Currently wordpress is automatically redirecting to the Amazon hostname `ec2-107-22-241-162.compute-1.amazonaws.com`, requesting users register, if I update wp-config.php by uncommenting `DOMAIN_CURRENT_S... | As @Rarst said, use PHP code inside a post content is bad habit. But you can use another workaround to show a section only for appropriate users.
Add the following code into your `functions.php` file:
```
add_shortcode( 'if_user_can', 'wpse8170_show_content_if_user_can' );
function wpse8170_show_content_if_user_can( ... |
114,181 | <p>I want to load the <code>page.php</code> template with the content I specify (using variables and not from the database) if the request contains a particular query string.</p>
<p>So lets say a user requests <code>example.com/?var1=str1</code> the page template should be displayed with the title and content I specif... | [
{
"answer_id": 114182,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": false,
"text": "<p>You can achieve that with filters on <a href=\"http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content\... | 2013/09/14 | [
"https://wordpress.stackexchange.com/questions/114181",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37396/"
] | I want to load the `page.php` template with the content I specify (using variables and not from the database) if the request contains a particular query string.
So lets say a user requests `example.com/?var1=str1` the page template should be displayed with the title and content I specify using variables.
This is the ... | You can achieve that with filters on [`the_content`](http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content) and [`the_title`](http://codex.wordpress.org/Plugin_API/Filter_Reference/the_title):
```
function wpa_content_filter( $content ) {
if( isset( $_REQUEST['var1'] ) && $_REQUEST['var1'] == "str1" )... |
114,197 | <p>Is there a way to make wordpress default color picker (iris) showed up over form and text using wordpress api?</p>
<p>Its inline display messing up the administration page of my plugin each time the color picker box showed up.</p>
| [
{
"answer_id": 114182,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": false,
"text": "<p>You can achieve that with filters on <a href=\"http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content\... | 2013/09/15 | [
"https://wordpress.stackexchange.com/questions/114197",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32989/"
] | Is there a way to make wordpress default color picker (iris) showed up over form and text using wordpress api?
Its inline display messing up the administration page of my plugin each time the color picker box showed up. | You can achieve that with filters on [`the_content`](http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content) and [`the_title`](http://codex.wordpress.org/Plugin_API/Filter_Reference/the_title):
```
function wpa_content_filter( $content ) {
if( isset( $_REQUEST['var1'] ) && $_REQUEST['var1'] == "str1" )... |
114,201 | <p>What is the proper approach to building translation strings?</p>
<p>For example, </p>
<pre><code>echo __( 'Hello ' . $first . ' you owe me money.' );
echo __( '<div><p>Top: ' . $t_margin . '</p>' . '<p>Bottom: ' . $b_margin . '</p></div>' )
</code></pre>
<p>Is it OK to add the ... | [
{
"answer_id": 114203,
"author": "Charles Clarkson",
"author_id": 31788,
"author_profile": "https://wordpress.stackexchange.com/users/31788",
"pm_score": 7,
"selected": true,
"text": "<p>There is a second argument in the <a href=\"http://codex.wordpress.org/Function_Reference/_2\"><code>... | 2013/09/15 | [
"https://wordpress.stackexchange.com/questions/114201",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16641/"
] | What is the proper approach to building translation strings?
For example,
```
echo __( 'Hello ' . $first . ' you owe me money.' );
echo __( '<div><p>Top: ' . $t_margin . '</p>' . '<p>Bottom: ' . $b_margin . '</p></div>' )
```
Is it OK to add the strings and/or HTML or should it be done first and then run through t... | There is a second argument in the [`__()`](http://codex.wordpress.org/Function_Reference/_2) function. It should be set to the domain you are are using for your plugin or theme. In the examples below I use `'text_domain'`. Your domain string should be unique. It should not match any other domain string. Not using a tex... |
114,210 | <p>Is there any way to find similar/duplicate wordpress posts by post_content. </p>
<p>I have tried "Find Duplicates" plugin but it takes a lot of time to search since I have more than 7000 posts in my database. </p>
<p>What I want to achieve is search the posts published in current week with all the old posts and fi... | [
{
"answer_id": 114211,
"author": "Mayeenul Islam",
"author_id": 22728,
"author_profile": "https://wordpress.stackexchange.com/users/22728",
"pm_score": 1,
"selected": false,
"text": "<p>I got a very good result using <a href=\"http://wordpress.org/plugins/jetpack\" rel=\"nofollow\">JetPa... | 2013/09/15 | [
"https://wordpress.stackexchange.com/questions/114210",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34822/"
] | Is there any way to find similar/duplicate wordpress posts by post\_content.
I have tried "Find Duplicates" plugin but it takes a lot of time to search since I have more than 7000 posts in my database.
What I want to achieve is search the posts published in current week with all the old posts and find similar posts... | Try to use the following SQL query to fetch duplicate posts:
```
SELECT p2.*
FROM wp_posts AS p1
LEFT JOIN wp_posts AS p2 ON p1.post_content = p2.post_content
AND p2.ID < p1.ID
AND p1.post_type = p2.post_type
AND p1.post_status = p2.post_status
WHERE p1.post_type = 'post' AND p2.ID IS NOT NULL
``` |
114,241 | <p>TBH this is my first time doing as adding a custom <code>jquery</code> in a <code>wordpress</code> and i read like about 10-20 articles about it already and more i guess but there still something missing, so i did it like this, and please mention what Im doing wrong, and the jquery im adding is found <a href="http:/... | [
{
"answer_id": 114244,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 1,
"selected": false,
"text": "<p>As you can see on the Codex page: <a href=\"http://codex.wordpress.org/Function_Reference/wp_nav_menu\" rel=\"nofo... | 2013/09/15 | [
"https://wordpress.stackexchange.com/questions/114241",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38079/"
] | TBH this is my first time doing as adding a custom `jquery` in a `wordpress` and i read like about 10-20 articles about it already and more i guess but there still something missing, so i did it like this, and please mention what Im doing wrong, and the jquery im adding is found [here](http://tympanus.net/codrops/2010/... | In addition to @Wyck's answer, since you asked if you are doing anything wrong, I'd suggest that it is usually more correct to register and enqueue your scripts as you've already done with some scripts in `my_custom_function`, than it is to write scripts directly into the header.
That is, put this code:
```
$(fun... |
114,253 | <p>I have to implement a default class for HTML-Tables at WordPress. The wp-standard is <code><table></code></p>
<p>.. ist there any way to do this, that i get this output per default? <code><table class="abc xyz"></code></p>
<p>maybe with filters?</p>
| [
{
"answer_id": 114254,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 3,
"selected": true,
"text": "<p>In your case you need to add custom hook for <code>the_content</code> filter:</p>\n\n<pre><code>add_fil... | 2013/09/15 | [
"https://wordpress.stackexchange.com/questions/114253",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7688/"
] | I have to implement a default class for HTML-Tables at WordPress. The wp-standard is `<table>`
.. ist there any way to do this, that i get this output per default? `<table class="abc xyz">`
maybe with filters? | In your case you need to add custom hook for `the_content` filter:
```
add_filter( 'the_content', 'wpse8170_add_custom_table_class' );
function wpse8170_add_custom_table_class( $content ) {
return str_replace( '<table>', '<table class="mycustom-class">', $content );
}
```
Add this snippet to your `functions.php`... |
114,259 | <p>I have an issue similar to many others in the web, but still with no solution so far.</p>
<p>To remove query strings i've used the following code:</p>
<pre><code>function _remove_script_version( $src ){
$parts = explode( '?', $src );
return $parts[0];
}
add_filter( 'script_loader_src', '_remove_script_vers... | [
{
"answer_id": 114261,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 2,
"selected": true,
"text": "<p>First of all I would like to strongly recommend you to not remove query parts of javascript and styleshe... | 2013/09/15 | [
"https://wordpress.stackexchange.com/questions/114259",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37371/"
] | I have an issue similar to many others in the web, but still with no solution so far.
To remove query strings i've used the following code:
```
function _remove_script_version( $src ){
$parts = explode( '?', $src );
return $parts[0];
}
add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
add_fi... | First of all I would like to strongly recommend you to not remove query parts of javascript and stylesheet files. Why? Because they contain a version of a file.
Why do I need it for? We need to add version to each file (whenever it is possible) to prevent versions collisions. These collisions could appear when a new ... |
114,268 | <p>I have at the end of my blog page an element that shows / lists the next articles from page 2.</p>
<p>If there is no second page , this element shows nothing.</p>
<p>I would like to hide the element automatically, as long when there is no second page.</p>
<p>Once there is a second page, the item should be display... | [
{
"answer_id": 114269,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>Just move all of the markup into the <code>have_posts</code> block.</p>\n\n<pre><code>if ( is_home() &&a... | 2013/09/15 | [
"https://wordpress.stackexchange.com/questions/114268",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7688/"
] | I have at the end of my blog page an element that shows / lists the next articles from page 2.
If there is no second page , this element shows nothing.
I would like to hide the element automatically, as long when there is no second page.
Once there is a second page, the item should be displayed automatically.
Does ... | You can use 2 properties of the global `WP_Query`: `max_num_pages` and `paged`.
After that avoid using `query_posts` for the new query use a new instance of `WP_Query` or `get_posts`.
```
global $wp_query;
if ($wp_query->max_num_pages > 1 && $wp_query->get('paged') < $wp_query->max_num_pages ) {
$next_page = (int)$... |
114,271 | <p>I'm using this code and getting only a forward slash for results. I'm trying to print the parent category of a WooCommerce product.</p>
<pre><code>$prod_cat = get_category_parents($product->id);
echo $prod_cat;
</code></pre>
<p>Any idea how to modify it so it prints the parent categories name?</p>
| [
{
"answer_id": 114269,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>Just move all of the markup into the <code>have_posts</code> block.</p>\n\n<pre><code>if ( is_home() &&a... | 2013/09/15 | [
"https://wordpress.stackexchange.com/questions/114271",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37880/"
] | I'm using this code and getting only a forward slash for results. I'm trying to print the parent category of a WooCommerce product.
```
$prod_cat = get_category_parents($product->id);
echo $prod_cat;
```
Any idea how to modify it so it prints the parent categories name? | You can use 2 properties of the global `WP_Query`: `max_num_pages` and `paged`.
After that avoid using `query_posts` for the new query use a new instance of `WP_Query` or `get_posts`.
```
global $wp_query;
if ($wp_query->max_num_pages > 1 && $wp_query->get('paged') < $wp_query->max_num_pages ) {
$next_page = (int)$... |
114,308 | <p>I'm trying to find out the index of the post which is currently viewed (single post page).</p>
<p>I have an overview of the articles in the same category in a sidebar. But when a user navigates to a post which is located on page 2, the articles should now show up the articles of page 2, even when in single post pag... | [
{
"answer_id": 114315,
"author": "Matt.C",
"author_id": 35780,
"author_profile": "https://wordpress.stackexchange.com/users/35780",
"pm_score": 0,
"selected": false,
"text": "<p>Using the $wp_query object, you can get the ID of the post outside the loop from post->ID</p>\n\n<pre><code> ... | 2013/09/16 | [
"https://wordpress.stackexchange.com/questions/114308",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35076/"
] | I'm trying to find out the index of the post which is currently viewed (single post page).
I have an overview of the articles in the same category in a sidebar. But when a user navigates to a post which is located on page 2, the articles should now show up the articles of page 2, even when in single post page.
This i... | The problem of your code is that `$wp_query` is a global variable. Once the sidebar is loaded via a function (`dynamic_sidebar`) you need to *globalize* that variable before use.
However, once you are in the single view the current\_post is always 0. You have to run another query, loop it, and check the every post id ... |
114,311 | <p>I know there are similar topics with accepted answers but I can't find what I'm looking for. I want to keep only basic buttons in <code>wp_editor()</code>. I'm using this in an option page to make writing more comfortable.</p>
<p>The problem is the theme adds a huge amount of quicktags I do not want on this specifi... | [
{
"answer_id": 114356,
"author": "Matt.C",
"author_id": 35780,
"author_profile": "https://wordpress.stackexchange.com/users/35780",
"pm_score": 1,
"selected": false,
"text": "<p>The following code works for me, it adds an options page, and adds a WYSIWYG box to that page, with ONLY 3 qui... | 2013/09/16 | [
"https://wordpress.stackexchange.com/questions/114311",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31376/"
] | I know there are similar topics with accepted answers but I can't find what I'm looking for. I want to keep only basic buttons in `wp_editor()`. I'm using this in an option page to make writing more comfortable.
The problem is the theme adds a huge amount of quicktags I do not want on this specific page. How can I ach... | If you are using the settings API, you can use exactly the same code for calling wp\_editor as you would anywhere else
I've test the code below, it adds a setting section to the reading section, and then adds a field to the section containing a WYSIWYG editor with buttons limited to link, img and close
```
// Add a s... |
114,312 | <p>My wordpress loads whole jQuery UI library</p>
<pre><code><script type='text/javascript' src='http://example.com/wp-includes/js/jquery/ui/jquery.ui.core.min.js?ver=1.9.2'></script>
<script type='text/javascript' src='http://example.com/wp-includes/js/jquery/ui/jquery.ui.widget.min.js?ver=1.9.2'>&l... | [
{
"answer_id": 114314,
"author": "Johannes Pille",
"author_id": 9745,
"author_profile": "https://wordpress.stackexchange.com/users/9745",
"pm_score": 3,
"selected": true,
"text": "<p>jQuery-UI is <em>included</em> in every default WP installation.<br>\nWhether it is <em>loaded</em> depen... | 2013/09/16 | [
"https://wordpress.stackexchange.com/questions/114312",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29076/"
] | My wordpress loads whole jQuery UI library
```
<script type='text/javascript' src='http://example.com/wp-includes/js/jquery/ui/jquery.ui.core.min.js?ver=1.9.2'></script>
<script type='text/javascript' src='http://example.com/wp-includes/js/jquery/ui/jquery.ui.widget.min.js?ver=1.9.2'></script>
<script type='text/javas... | jQuery-UI is *included* in every default WP installation.
Whether it is *loaded* depends on your theme and/or plugin(s).
Three Options:
* live with it
* disable plugins one by one (and switch theme), figure out which is responsible and whether that's needed
* manually [deregister](http://codex.wordpress.org/Functi... |
114,332 | <p>I am building a plugin which has a file upload field in it's settings page. The files should not be image files but should be .doc, .txt etc. Struggling with the code for it. Any help would be greatly appreciated !</p>
<p>Edit 1:
Here is the code - </p>
<pre><code>$options = get_option('nn_sub_general_options');
i... | [
{
"answer_id": 114452,
"author": "Vikas Gautam",
"author_id": 38149,
"author_profile": "https://wordpress.stackexchange.com/users/38149",
"pm_score": 0,
"selected": false,
"text": "<pre><code>$allowedExts = array(\"gif\", \"jpeg\", \"jpg\", \"png\"); \n$temp = explode(\".\", $_FILES[\"fi... | 2013/09/16 | [
"https://wordpress.stackexchange.com/questions/114332",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37341/"
] | I am building a plugin which has a file upload field in it's settings page. The files should not be image files but should be .doc, .txt etc. Struggling with the code for it. Any help would be greatly appreciated !
Edit 1:
Here is the code -
```
$options = get_option('nn_sub_general_options');
if(!isset($options['nn... | First do a `var_dump` on the `$_FILES` variable to check if the array key you are using is the correct one, and you should never just grab a variable that comes from user input and just use it, try doing a `isset` or `empty` before you use the variable.
After you found what is the key you will use [`wp_check_filetype`... |
114,339 | <p>I have a custom post type that has a custom taxonomy which functions as the main hierarchical structure for this custom post type. I am experiencing some behavior that I can't explain though.</p>
<p>This hierarchical structure is 3 levels deep as following:</p>
<p>main<br>
-section<br>
--subsection</p>
<p>The ide... | [
{
"answer_id": 114452,
"author": "Vikas Gautam",
"author_id": 38149,
"author_profile": "https://wordpress.stackexchange.com/users/38149",
"pm_score": 0,
"selected": false,
"text": "<pre><code>$allowedExts = array(\"gif\", \"jpeg\", \"jpg\", \"png\"); \n$temp = explode(\".\", $_FILES[\"fi... | 2013/09/16 | [
"https://wordpress.stackexchange.com/questions/114339",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37684/"
] | I have a custom post type that has a custom taxonomy which functions as the main hierarchical structure for this custom post type. I am experiencing some behavior that I can't explain though.
This hierarchical structure is 3 levels deep as following:
main
-section
--subsection
The idea is that every custom pos... | First do a `var_dump` on the `$_FILES` variable to check if the array key you are using is the correct one, and you should never just grab a variable that comes from user input and just use it, try doing a `isset` or `empty` before you use the variable.
After you found what is the key you will use [`wp_check_filetype`... |
114,369 | <p>I am eperiencing a very annoying problem. I built my website with media queries and is_mobile (thinking is_mobile would be the same as smaller screens. How foolish of me.) but after some testing apparently the iPad kind of screws it up (okay, actually I did).</p>
<p>All my problems could easily be solved if I could... | [
{
"answer_id": 114378,
"author": "tfrommen",
"author_id": 27722,
"author_profile": "https://wordpress.stackexchange.com/users/27722",
"pm_score": 2,
"selected": false,
"text": "<p><s>\nI've rewritten (and, in my opinion, optimized) your function a bit:</p>\n\n<pre><code>function wp_is_mo... | 2013/09/16 | [
"https://wordpress.stackexchange.com/questions/114369",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16574/"
] | I am eperiencing a very annoying problem. I built my website with media queries and is\_mobile (thinking is\_mobile would be the same as smaller screens. How foolish of me.) but after some testing apparently the iPad kind of screws it up (okay, actually I did).
All my problems could easily be solved if I could exclude... | t f's answer got me thinking. Actually, I can use the core function and adapt it as I like but just put everything in a new function. So here goes:
```
function my_wp_is_mobile() {
static $is_mobile;
if ( isset($is_mobile) )
return $is_mobile;
if ( empty($_SERVER['HTTP_USER_AGENT']) ) {
$... |
114,373 | <p>I'm new to Wordpress. I'm trying to create a Wordpress theme.
But i am getting the error:</p>
<pre><code>Parse error: syntax error, unexpected 'meta' (T_STRING) in \xampp\htdocs\wordpress\wp-content\themes\theme\index.php on line 31
</code></pre>
<p>Error File <strong>Index.php</strong></p>
<pre><code> <?ph... | [
{
"answer_id": 114375,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 0,
"selected": false,
"text": "<p>Try this instead on line 31, your quotes are not consistent:</p>\n\n<pre><code><?php the_tags( '<span... | 2013/09/16 | [
"https://wordpress.stackexchange.com/questions/114373",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38126/"
] | I'm new to Wordpress. I'm trying to create a Wordpress theme.
But i am getting the error:
```
Parse error: syntax error, unexpected 'meta' (T_STRING) in \xampp\htdocs\wordpress\wp-content\themes\theme\index.php on line 31
```
Error File **Index.php**
```
<?php get_header(); ?>
<div id="container">
<div id=... | use single quotes outside of the following statement, why you are getting this error because you are using double quotes for class attribute `"</span><span class="meta-sep">|</span>"` and also wrapping it in double quotes.
replace this
`"</span><span class="meta-sep">|</span>"`
with
`'</span><span class="meta-sep">... |
114,398 | <p>I have been trying to get this to work for awhile now and I cannot seem to get any farther on my own. It seems to work fine as a normal SQL query but not within the WP framework using <a href="http://codex.wordpress.org/Class_Reference/wpdb" rel="nofollow">prepare()</a>. Basically I am trying to insert a PHP varia... | [
{
"answer_id": 114400,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 1,
"selected": false,
"text": "<p>Try this:</p>\n\n<pre><code>global $wpdb;\n$forum_id = bbp_get_forum_id();\n$countquery = $wpdb->get_var( \n... | 2013/09/16 | [
"https://wordpress.stackexchange.com/questions/114398",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35327/"
] | I have been trying to get this to work for awhile now and I cannot seem to get any farther on my own. It seems to work fine as a normal SQL query but not within the WP framework using [prepare()](http://codex.wordpress.org/Class_Reference/wpdb). Basically I am trying to insert a PHP variable within the SQL query but in... | The function `bbp_forum_id()` will directly `echo` its value, you want to use `bbp_get_forum_id()` which will `return` the value for use in the context of an API call. |
114,415 | <p>I'm pretty new to coding for Wordpress, bear with me.</p>
<p>I have a section on my home page, that lists the 2 most recent blog posts.</p>
<p>If the text goes past three lines, my design gets messed up. So I was wondering if there was a native function that exists for me to append 'Continue Reading' automagically... | [
{
"answer_id": 114418,
"author": "Andre Yonadam",
"author_id": 37385,
"author_profile": "https://wordpress.stackexchange.com/users/37385",
"pm_score": 1,
"selected": false,
"text": "<p>Instead of doing the lines, I would try to go for characters or words. The example below uses character... | 2013/09/17 | [
"https://wordpress.stackexchange.com/questions/114415",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38138/"
] | I'm pretty new to coding for Wordpress, bear with me.
I have a section on my home page, that lists the 2 most recent blog posts.
If the text goes past three lines, my design gets messed up. So I was wondering if there was a native function that exists for me to append 'Continue Reading' automagically and allow the us... | Instead of doing the lines, I would try to go for characters or words. The example below uses characters.
Don't take my word on it as it hasn't been tested.
```
$character == 40; // number of characters to compare
if(mb_strlen( get_the_content() < $character){
the_content();
}else{
the_content('Continue Reading...')
... |
114,439 | <p>Not sure if this is a bug or by design, but it's damn annoying. Every so often, more so after updating the core, while in the admin section, I get booted out with the infamous "Your session has expired" message. Strange in itself since apparently WP doesn't use sessions. The login prompt comes with a "remember me" c... | [
{
"answer_id": 264794,
"author": "Aishan",
"author_id": 89530,
"author_profile": "https://wordpress.stackexchange.com/users/89530",
"pm_score": 4,
"selected": false,
"text": "<p>By default, WordPress makes your login session cookie expire in 48 hours (or on browser close), or 14 days if ... | 2013/09/17 | [
"https://wordpress.stackexchange.com/questions/114439",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36977/"
] | Not sure if this is a bug or by design, but it's damn annoying. Every so often, more so after updating the core, while in the admin section, I get booted out with the infamous "Your session has expired" message. Strange in itself since apparently WP doesn't use sessions. The login prompt comes with a "remember me" chec... | By default, WordPress makes your login session cookie expire in 48 hours (or on browser close), or 14 days if you check the “Remember Me” box.
Maybe you have some plugins which force your login cookie to expire.
You could manually add the code below on your `functions.php` to extend your cookie expiry to whatever tim... |
114,449 | <p>I have a plugin class which contains a function spektrix_list_events()</p>
<pre><code>class SpektrixPlugin {
public function __construct(){
add_action( 'init', array ( $this, 'init' ));
}
public function init()
{
add_action( 'spektrix_list_events', array ( $this, 'spektrix_list_ev... | [
{
"answer_id": 114456,
"author": "sun",
"author_id": 35819,
"author_profile": "https://wordpress.stackexchange.com/users/35819",
"pm_score": -1,
"selected": false,
"text": "<p>If you want any function to work juhst hook it to your appropriate needs.I think in your case you want to execut... | 2013/09/17 | [
"https://wordpress.stackexchange.com/questions/114449",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/500/"
] | I have a plugin class which contains a function spektrix\_list\_events()
```
class SpektrixPlugin {
public function __construct(){
add_action( 'init', array ( $this, 'init' ));
}
public function init()
{
add_action( 'spektrix_list_events', array ( $this, 'spektrix_list_events' ));
... | Some actions hooks need to be fired on specific events. Try this code:
```
class SpektrixPlugin {
public function __construct(){
add_action('init', array(&$this, 'init'));
}
public function spektrix_list_events($getPrices = FALSE) {
$api = new SpektrixApiClient();
return $api->get... |
114,472 | <p>I've successfully made wp-admin not accessible (redirected to 404 page)
here is the codes in my function file:</p>
<pre><code>add_filter('site_url', 'wpadmin_filter', 10, 3);
function wpadmin_filter( $url, $path, $orig_scheme ) {
$old = array( "/(wp-admin)/");
$admin_dir = WP_ADMIN_DIR;
$new = array($a... | [
{
"answer_id": 114479,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 1,
"selected": false,
"text": "<p>Instead of filtering the <code>site_url</code> you should be filtering <code>adim_url</code> and <code>login_... | 2013/09/17 | [
"https://wordpress.stackexchange.com/questions/114472",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32872/"
] | I've successfully made wp-admin not accessible (redirected to 404 page)
here is the codes in my function file:
```
add_filter('site_url', 'wpadmin_filter', 10, 3);
function wpadmin_filter( $url, $path, $orig_scheme ) {
$old = array( "/(wp-admin)/");
$admin_dir = WP_ADMIN_DIR;
$new = array($admin_dir);
... | Instead of filtering the `site_url` you should be filtering `adim_url` and `login_url`
```
add_filter('admin_url', 'new_admin_url');
function new_admin_url()
{
// Insert the new URL here:
return get_bloginfo('url').'/controlpanel/';
}
add_filter( 'login_url', 'new_login_url', 10, 2 );
function new_login_url... |
114,477 | <p>An existing website have many images placed within the content of pages.
I'd like to redesign the template, separating the display of text and images.
How could i do that?</p>
| [
{
"answer_id": 114483,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 4,
"selected": true,
"text": "<p>You could use, for example, <code>the_content</code> filter, run a regex to remove the images and grab them in... | 2013/09/17 | [
"https://wordpress.stackexchange.com/questions/114477",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25845/"
] | An existing website have many images placed within the content of pages.
I'd like to redesign the template, separating the display of text and images.
How could i do that? | You could use, for example, `the_content` filter, run a regex to remove the images and grab them in a variable, then print that variable wherever you want.
For example, appending all images to the end of the content:
```
add_filter( 'the_content', 'my_the_content_filter' );
function my_the_content_filter($content) {
... |
114,488 | <p>I am using wordpress in my magento using Fishpig wordpress extension, i have created a functions in functions.php of my theme (though its full integrated, meaning magento theme is applied to blog) but the following function doesn't seem to have any effort. my function is</p>
<pre><code>add_filter( 'the_excerpt_rss'... | [
{
"answer_id": 114483,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 4,
"selected": true,
"text": "<p>You could use, for example, <code>the_content</code> filter, run a regex to remove the images and grab them in... | 2013/09/17 | [
"https://wordpress.stackexchange.com/questions/114488",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33028/"
] | I am using wordpress in my magento using Fishpig wordpress extension, i have created a functions in functions.php of my theme (though its full integrated, meaning magento theme is applied to blog) but the following function doesn't seem to have any effort. my function is
```
add_filter( 'the_excerpt_rss', 'insert_thum... | You could use, for example, `the_content` filter, run a regex to remove the images and grab them in a variable, then print that variable wherever you want.
For example, appending all images to the end of the content:
```
add_filter( 'the_content', 'my_the_content_filter' );
function my_the_content_filter($content) {
... |
114,490 | <p>I have a site where I used <code>http://example.com</code>, but if I change my site URL to <code>http://example.co.uk</code> or <code>http://examplesite.co.uk</code> which are all same site.</p>
<p>If I changed anything in the above urls it should override theme url.</p>
<p>Currently it is showing from the databas... | [
{
"answer_id": 114503,
"author": "Manish",
"author_id": 37569,
"author_profile": "https://wordpress.stackexchange.com/users/37569",
"pm_score": 0,
"selected": false,
"text": "<p>Instead of <code>$_SERVER['HTTP_HOST']</code> write hard coded value and check if it is working.</p>\n"
},
... | 2013/09/17 | [
"https://wordpress.stackexchange.com/questions/114490",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17849/"
] | I have a site where I used `http://example.com`, but if I change my site URL to `http://example.co.uk` or `http://examplesite.co.uk` which are all same site.
If I changed anything in the above urls it should override theme url.
Currently it is showing from the database value.
I used
```
define('WP_HOME', 'http:/... | In a comment I pointed you to an existing answer that I figured would solve your problem.
You replied
>
> thanks for answering. but it is working for bloginfo('url') & not for bloginfo('template\_url'). Any ideas?
>
>
>
The answer I pointed you to is easily adaptable for that:
In your `wp-config.php` file, *af... |
114,506 | <p>I created the Plugin of my own. Everything seems OK but one thing I want to do in that plugin is redirect to the corresponding plugin settings page when the plugin is activate.</p>
<p><strong>For example:</strong><br>
<code>http://www.example.com/wordpress/wp-admin/options-general.php?page=rotator</code></p>
<p>Is... | [
{
"answer_id": 114509,
"author": "iEmanuele",
"author_id": 35646,
"author_profile": "https://wordpress.stackexchange.com/users/35646",
"pm_score": 3,
"selected": false,
"text": "<p>You should be able to do it like this:</p>\n\n<pre><code>register_activation_hook(__FILE__, 'my_plugin_acti... | 2013/09/17 | [
"https://wordpress.stackexchange.com/questions/114506",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24481/"
] | I created the Plugin of my own. Everything seems OK but one thing I want to do in that plugin is redirect to the corresponding plugin settings page when the plugin is activate.
**For example:**
`http://www.example.com/wordpress/wp-admin/options-general.php?page=rotator`
Is there a way to redirect to the correspond... | Maybe using the [`wp_redirect()`](http://codex.wordpress.org/Function_Reference/wp_redirect) function in the activation hook. In the following example `myplugin_settings` is a placeholder. Normally this simply is the `$hook_suffix` you get back from `$hook_suffix = add_menu_page( /* etc. */ );` and similar functions.
... |
114,547 | <p>I need to get posts from a certain timeframe.
I am using the <code>posts_where</code> filter.</p>
<p>I want to specify a beginning date and an end date.
This is the function I use:</p>
<pre><code>function filter_where( $where = '' ) {
$where .= " AND post_date >= '2012-03-01' AND post_date =< '2014-03-01... | [
{
"answer_id": 114509,
"author": "iEmanuele",
"author_id": 35646,
"author_profile": "https://wordpress.stackexchange.com/users/35646",
"pm_score": 3,
"selected": false,
"text": "<p>You should be able to do it like this:</p>\n\n<pre><code>register_activation_hook(__FILE__, 'my_plugin_acti... | 2013/09/17 | [
"https://wordpress.stackexchange.com/questions/114547",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28280/"
] | I need to get posts from a certain timeframe.
I am using the `posts_where` filter.
I want to specify a beginning date and an end date.
This is the function I use:
```
function filter_where( $where = '' ) {
$where .= " AND post_date >= '2012-03-01' AND post_date =< '2014-03-01'";
return $where;
}
```
This Fi... | Maybe using the [`wp_redirect()`](http://codex.wordpress.org/Function_Reference/wp_redirect) function in the activation hook. In the following example `myplugin_settings` is a placeholder. Normally this simply is the `$hook_suffix` you get back from `$hook_suffix = add_menu_page( /* etc. */ );` and similar functions.
... |
114,581 | <p>If I have a store that offers flat rate shipping of <code>$10</code> and free shipping for orders over $100 and a customer orders over <code>$100</code> it doesn't make much sense for them to have to see both <code>free shipping</code> and <code>flat rate shipping</code> on the checkout page. Why would a user even c... | [
{
"answer_id": 114509,
"author": "iEmanuele",
"author_id": 35646,
"author_profile": "https://wordpress.stackexchange.com/users/35646",
"pm_score": 3,
"selected": false,
"text": "<p>You should be able to do it like this:</p>\n\n<pre><code>register_activation_hook(__FILE__, 'my_plugin_acti... | 2013/09/17 | [
"https://wordpress.stackexchange.com/questions/114581",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19620/"
] | If I have a store that offers flat rate shipping of `$10` and free shipping for orders over $100 and a customer orders over `$100` it doesn't make much sense for them to have to see both `free shipping` and `flat rate shipping` on the checkout page. Why would a user even choose `flat rate shipping`?
How can I use a fi... | Maybe using the [`wp_redirect()`](http://codex.wordpress.org/Function_Reference/wp_redirect) function in the activation hook. In the following example `myplugin_settings` is a placeholder. Normally this simply is the `$hook_suffix` you get back from `$hook_suffix = add_menu_page( /* etc. */ );` and similar functions.
... |
114,589 | <p>Right now I am using:</p>
<pre><code>$wp_query->post->ID;
</code></pre>
<p>I want to know if there is a better way for getting the post id that consumes less resources?</p>
| [
{
"answer_id": 114590,
"author": "Johannes Pille",
"author_id": 9745,
"author_profile": "https://wordpress.stackexchange.com/users/9745",
"pm_score": 3,
"selected": true,
"text": "<p>An alternative to your way would be to access the <code>$post</code> global:</p>\n\n<pre><code>global $po... | 2013/09/17 | [
"https://wordpress.stackexchange.com/questions/114589",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14128/"
] | Right now I am using:
```
$wp_query->post->ID;
```
I want to know if there is a better way for getting the post id that consumes less resources? | An alternative to your way would be to access the `$post` global:
```
global $post
echo $post->ID;
```
But
1. It won't make a noticeable difference, either way
2. If you want to increase efficiency, you ought to be looking elsewhere...
**EDIT**, pertaining to comments:
>
> what about `get_the_ID();`?
>
>
>
-... |
114,611 | <p>I need some way to hide theme built in widget from one category.So when the post is from category X on that post hide that widget. I would use plugin for it, but since it's not drag and drop widget I can't. It's a ticker list which is built inside the theme. I have tried with <code><?php if(!in_category('X')) : ?... | [
{
"answer_id": 114612,
"author": "Wrought_steel",
"author_id": 38098,
"author_profile": "https://wordpress.stackexchange.com/users/38098",
"pm_score": 1,
"selected": false,
"text": "<p>I think you might mean <code>is_category()</code>?</p>\n\n<p><strong>Codex:</strong> <a href=\"http://c... | 2013/09/18 | [
"https://wordpress.stackexchange.com/questions/114611",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38207/"
] | I need some way to hide theme built in widget from one category.So when the post is from category X on that post hide that widget. I would use plugin for it, but since it's not drag and drop widget I can't. It's a ticker list which is built inside the theme. I have tried with `<?php if(!in_category('X')) : ?>` like I d... | I think you might mean `is_category()`?
**Codex:** [`is_category()`](http://codex.wordpress.org/Function_Reference/is_category) |
114,645 | <p>E.g. I set this in header.php in my template:</p>
<pre><code><?php $postidextra = get_the_ID(); ?>
<?php $sidebar_state = get_post_meta($postidextra , 'rw_sidebar_state', true); ?>
</code></pre>
<p>And I can echo $sidebar_state in header.php, it's working.</p>
<p>However, when I try to echo this vari... | [
{
"answer_id": 114649,
"author": "Got The Fever Media",
"author_id": 28153,
"author_profile": "https://wordpress.stackexchange.com/users/28153",
"pm_score": 2,
"selected": false,
"text": "<p>the codex states that you can only use <code>get_the_id()</code> in <a href=\"http://codex.wordpr... | 2013/09/18 | [
"https://wordpress.stackexchange.com/questions/114645",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17368/"
] | E.g. I set this in header.php in my template:
```
<?php $postidextra = get_the_ID(); ?>
<?php $sidebar_state = get_post_meta($postidextra , 'rw_sidebar_state', true); ?>
```
And I can echo $sidebar\_state in header.php, it's working.
However, when I try to echo this variable from footer.php or page.php it's not wo... | the codex states that you can only use `get_the_id()` in [the Loop](http://codex.wordpress.org/Function_Reference/get_the_ID) |
114,657 | <p>In order to parallelize downloads, i created already a subdomain for images. images.mydomain.com</p>
<p>Now, i don't know how to move my media files, without breaking attachments, and after that, in the future, how to automatically store media file in subdomain.</p>
<p>Eventually, what i was thinking of doing was ... | [
{
"answer_id": 114663,
"author": "Maruti Mohanty",
"author_id": 37890,
"author_profile": "https://wordpress.stackexchange.com/users/37890",
"pm_score": 3,
"selected": true,
"text": "<p>You can move the uploads folder to the sub domain by doing this</p>\n\n<p>Open up your wp-config.php fi... | 2013/09/18 | [
"https://wordpress.stackexchange.com/questions/114657",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37371/"
] | In order to parallelize downloads, i created already a subdomain for images. images.mydomain.com
Now, i don't know how to move my media files, without breaking attachments, and after that, in the future, how to automatically store media file in subdomain.
Eventually, what i was thinking of doing was something like , ... | You can move the uploads folder to the sub domain by doing this
Open up your wp-config.php file, located at the root of your WordPress installation, and add the following code:
```
define('UPLOADS', 'http://images.mydomain.com/uploads');
```
The codex specifies that it should be added before the line that says requ... |
114,679 | <p>I have a custom template which should only show posts of specific categories. What do i need to change inside this code, to get this done?</p>
<pre><code>if ( ! function_exists( 'attitude_theloop_for_template_blog_full_content_one' ) ) :
/**
* Fuction to show the content of page template full content display.
*/
... | [
{
"answer_id": 114681,
"author": "Maruti Mohanty",
"author_id": 37890,
"author_profile": "https://wordpress.stackexchange.com/users/37890",
"pm_score": 2,
"selected": false,
"text": "<p>You can do that by using category parameter in the wp_query</p>\n\n<p>change the line which looks like... | 2013/09/18 | [
"https://wordpress.stackexchange.com/questions/114679",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38216/"
] | I have a custom template which should only show posts of specific categories. What do i need to change inside this code, to get this done?
```
if ( ! function_exists( 'attitude_theloop_for_template_blog_full_content_one' ) ) :
/**
* Fuction to show the content of page template full content display.
*/
function attit... | You can do that by using category parameter in the wp\_query
change the line which looks like this
```
$blog_query = new WP_Query( array( 'post_type' => 'post', 'paged' => $paged ) );
```
to
```
$blog_query = new WP_Query( array( 'post_type' => 'post', 'paged' => $paged, 'cat' => 4 ) );
```
// Here '4' is the id... |
114,717 | <p>'m using human made's custom meta boxes framework (<a href="https://github.com/humanmade/Custom-Meta-Boxes" rel="nofollow">https://github.com/humanmade/Custom-Meta-Boxes</a>). Using the post select:</p>
<pre><code>array(
'id' => 'example-field-post-select',
'name' => 'Post Select Field',
... | [
{
"answer_id": 115301,
"author": "Matth_eu",
"author_id": 13202,
"author_profile": "https://wordpress.stackexchange.com/users/13202",
"pm_score": 1,
"selected": false,
"text": "<p>Unfortunately it is not possible to modify the field to use the name instead of ID and to keep the AJAX func... | 2013/09/18 | [
"https://wordpress.stackexchange.com/questions/114717",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37054/"
] | 'm using human made's custom meta boxes framework (<https://github.com/humanmade/Custom-Meta-Boxes>). Using the post select:
```
array(
'id' => 'example-field-post-select',
'name' => 'Post Select Field',
'type' => 'post_select',
'use_ajax' => true,
'query' => array( 'post_type' =>... | Unfortunately it is not possible to modify the field to use the name instead of ID and to keep the AJAX functionality.
You could use a standard select field, and pass the post data in the desired format to this - although you will loose the AJAX functionality.
The only way to achieve 100% of what you want is to creat... |
114,719 | <p>There's a few questions on this site referencing this issue and I've read them and applied the proposed solutions to no avail.</p>
<p>I've made a very simple theme options page that appears for the Editor role but when an Editor tries to save the options they get the "Cheatin 'Uh?" message.</p>
<p>The following is... | [
{
"answer_id": 114764,
"author": "neil.odiaz",
"author_id": 38224,
"author_profile": "https://wordpress.stackexchange.com/users/38224",
"pm_score": 1,
"selected": false,
"text": "<p>This <a href=\"http://wordpress.org/plugins/members/\" rel=\"nofollow\">plugin</a> may help. Allows you to... | 2013/09/18 | [
"https://wordpress.stackexchange.com/questions/114719",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29158/"
] | There's a few questions on this site referencing this issue and I've read them and applied the proposed solutions to no avail.
I've made a very simple theme options page that appears for the Editor role but when an Editor tries to save the options they get the "Cheatin 'Uh?" message.
The following is my options code:... | There's a bug(ish) report regarding this here:
<http://make.wordpress.org/themes/2011/07/01/wordpress-3-2-fixing-the-edit_theme_optionsmanage_options-bug/>
You can use a filter to modify the theme page capability. First you'll want to edit your `register_setting()` calls to look like this:
```
register_setting( 'map-... |
114,741 | <p>I'm creating a template but every time I add a new custom post type (in this example neighborhood) it keeps injecting a new <code><ol></code> and <code><li></code> here is the code I currently have and I'm using the ACF Advanced Custom Fields plugin to create my custom fields.</p>
<pre><code><?php
/... | [
{
"answer_id": 114722,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>IIRC it's if a post is password protected.</p>\n"
},
{
"answer_id": 114740,
"author": "Ben Miller - Re... | 2013/09/18 | [
"https://wordpress.stackexchange.com/questions/114741",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35567/"
] | I'm creating a template but every time I add a new custom post type (in this example neighborhood) it keeps injecting a new `<ol>` and `<li>` here is the code I currently have and I'm using the ACF Advanced Custom Fields plugin to create my custom fields.
```
<?php
/*
Template Name: Neighborhoods Page
*/
include... | [`register_post_status`](https://developer.wordpress.org/reference/functions/register_post_status/) is used for creating a custom post status. The protected argument, if true, specifies that a user must be logged in and have edit permissions on the post to view (preview) it.
For example, you said that the "draft" post... |
114,768 | <p>I've set up a dev site for a client, for who we're overhauling their existing site.</p>
<p>One thing I wanted to do is import all their existing news posts, and carry over any images attached to those. I've managed to export the attachments WP Attachment Export plugin. The xml file appears to be all fine, and the c... | [
{
"answer_id": 115089,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": true,
"text": "<p>I think that importing attachments separately (which is not possible with native export) is precisely cause for your... | 2013/09/19 | [
"https://wordpress.stackexchange.com/questions/114768",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10886/"
] | I've set up a dev site for a client, for who we're overhauling their existing site.
One thing I wanted to do is import all their existing news posts, and carry over any images attached to those. I've managed to export the attachments WP Attachment Export plugin. The xml file appears to be all fine, and the correct val... | I think that importing attachments separately (which is not possible with native export) is precisely cause for your issue. Importer plugin has following code:
```
if ( $post_parent ) {
// if we already know the parent, map it to the new local ID
if ( isset( $this->processed_posts[$post_parent] ) ) {
... |
114,800 | <p>I have a custom query which gets all the custom taxonomies for the custom post type and displays the latest post in each. At the moment it pulls in <em>all</em> the taxonomies. Is there a way I can limit the number of taxonomies displayed to a set number per page and paginate them?</p>
<pre><code>// Set post type
$... | [
{
"answer_id": 114873,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 3,
"selected": true,
"text": "<p>You <strong>have</strong> to develop with <a href=\"http://codex.wordpress.org/Debugging_in_WordPress\" rel=... | 2013/09/19 | [
"https://wordpress.stackexchange.com/questions/114800",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36275/"
] | I have a custom query which gets all the custom taxonomies for the custom post type and displays the latest post in each. At the moment it pulls in *all* the taxonomies. Is there a way I can limit the number of taxonomies displayed to a set number per page and paginate them?
```
// Set post type
$post_type = 'prints';... | You **have** to develop with [WP\_DEBUG](http://codex.wordpress.org/Debugging_in_WordPress) enabled. And use Firebug or Chrome Console to check for Network/JavaScript errors.
[](https://i.stack.imgur.com/uyWzY.png)
WP is trying to locate the folder *... |
114,801 | <p>I am new to Wordpress
I am setting up wordpress Site which has 3 Menus </p>
<ul>
<li>Top menu</li>
<li>Header Menu</li>
<li>Footer Menu </li>
</ul>
<p>My issue is I need to add the User name to My Top menu Only when User is Logged in </p>
<p>But using below Code snippet it adds the Custom menu Item in all the Men... | [
{
"answer_id": 114802,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 3,
"selected": true,
"text": "<p><code>wp_nav_menu_items</code> filters passes menu arguments as second parameter.</p>\n\n<p>So if you modify code to... | 2013/09/19 | [
"https://wordpress.stackexchange.com/questions/114801",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14872/"
] | I am new to Wordpress
I am setting up wordpress Site which has 3 Menus
* Top menu
* Header Menu
* Footer Menu
My issue is I need to add the User name to My Top menu Only when User is Logged in
But using below Code snippet it adds the Custom menu Item in all the Menus the Below Code i found while googleing the Solu... | `wp_nav_menu_items` filters passes menu arguments as second parameter.
So if you modify code to this:
```
add_filter( 'wp_nav_menu_items', 'my_custom_menu_item', 10, 2);
function my_custom_menu_item($items, $args) ...
```
You will be able to check data `$args` inside function to match specific menu. However the sp... |
114,807 | <p>I have this code for flexslider Shortcode</p>
<pre><code>add_shortcode('flexslider', function($atts){
global $post;
$ids = explode(',', $atts[ids]);
$uniqid = uniqid();
wp_enqueue_script( 'shortcode_flexslider');
wp_localize_script( 'shortcode_flexslider', 'slider', array('id' => $uniqid));
foreach( $ids as $... | [
{
"answer_id": 114822,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>Well...</p>\n\n<pre><code>wp_localize_script( 'shortcode_flexslider', 'slider', array('id' => $uniqid)); ... | 2013/09/19 | [
"https://wordpress.stackexchange.com/questions/114807",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35754/"
] | I have this code for flexslider Shortcode
```
add_shortcode('flexslider', function($atts){
global $post;
$ids = explode(',', $atts[ids]);
$uniqid = uniqid();
wp_enqueue_script( 'shortcode_flexslider');
wp_localize_script( 'shortcode_flexslider', 'slider', array('id' => $uniqid));
foreach( $ids as $id ) {
$imgLi... | Your ploblem is that `wp_localize_script` print to the html markup a javascript object similar to:
```
var slider = {"id":"a_unique_id_here"};
```
if you call it more times, e.g. using more shortcodes in same page, whati is printend in html markup is
```
var slider = {"id":"a_unique_id_here"};
var slider = {"id":"a... |
114,810 | <p>I would like to add parameter for the submenus, but when I click to the admin page I receive the following message:</p>
<blockquote>
<p>You do not have sufficient permissions to access this page.</p>
</blockquote>
<p><strong>Code:</strong></p>
<pre><code>add_submenu_page(
'sandbox',
'Sandbox... | [
{
"answer_id": 114818,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 3,
"selected": true,
"text": "<p>You'd have to manipulate the global <code>$submenu</code> and modify the link in it. Or use jQuery.</p>\n\n<... | 2013/09/19 | [
"https://wordpress.stackexchange.com/questions/114810",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38284/"
] | I would like to add parameter for the submenus, but when I click to the admin page I receive the following message:
>
> You do not have sufficient permissions to access this page.
>
>
>
**Code:**
```
add_submenu_page(
'sandbox',
'Sandbox Options',
'Options',
'admin... | You'd have to manipulate the global `$submenu` and modify the link in it. Or use jQuery.
The following example adds a submenu in the Dashboard menu and changes the destination link just after. The submenu page will dump the contents of the global var.
```
add_action( 'admin_menu', function()
{
add_submenu_page( ... |
114,830 | <p>I need to offer a zip file download [to registered users] on every post, containing all the images attached to the post. The <a href="https://wordpress.stackexchange.com/questions/99297/zip-up-all-images-displayed-in-a-gallery-and-offer-as-download-link">solution provided in this thread</a> works well for the purpos... | [
{
"answer_id": 114831,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 1,
"selected": false,
"text": "<p>As you can see, the code of the linked question add a custom gallery shortcode in this function:</p>\n\n<pre>... | 2013/09/19 | [
"https://wordpress.stackexchange.com/questions/114830",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25508/"
] | I need to offer a zip file download [to registered users] on every post, containing all the images attached to the post. The [solution provided in this thread](https://wordpress.stackexchange.com/questions/99297/zip-up-all-images-displayed-in-a-gallery-and-offer-as-download-link) works well for the purpose, although it... | Directory permission was an issue regarding this topic. As the plugin is activated it creates a folder named "galleryzip-cache" under the directory wp-content. The folder has it's permission set to 001 on its initial creation. If you set the permission to 775, it will work flawless.
All the credits and efforts goes to... |
114,838 | <p>I've just converted all of my blog posts to a CPT because I needed them to be hierarchical. Problem is, I had categories assigned to all of the posts. How can I use the standard WordPress categories in my CPT?</p>
<p>I've tried adding <code>'taxonomies' => array('category'),</code> to the <code>register_post_ty... | [
{
"answer_id": 114839,
"author": "Eric Holmes",
"author_id": 23454,
"author_profile": "https://wordpress.stackexchange.com/users/23454",
"pm_score": 3,
"selected": true,
"text": "<p>The answer lies in <a href=\"http://codex.wordpress.org/Function_Reference/register_taxonomy_for_object_ty... | 2013/09/19 | [
"https://wordpress.stackexchange.com/questions/114838",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3877/"
] | I've just converted all of my blog posts to a CPT because I needed them to be hierarchical. Problem is, I had categories assigned to all of the posts. How can I use the standard WordPress categories in my CPT?
I've tried adding `'taxonomies' => array('category'),` to the `register_post_type` function, but that didn't ... | The answer lies in [`register_taxonomy_for_object_type`](http://codex.wordpress.org/Function_Reference/register_taxonomy_for_object_type). Very simple usage.
You could also try passing the 'taxonomies' argument in your `register_post_type`. |
114,845 | <p>I am unable to set the year below 1899 for a post. If i set year below 1899 it is set to the current year automatically.</p>
<p><img src="https://i.stack.imgur.com/IC73X.gif" alt="screen shot"></p>
<p>I have purchased the <em>Timeline</em> theme and asked in their support forum. They replied:</p>
<blockquote>
<... | [
{
"answer_id": 115610,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": false,
"text": "<p>This is not really an answer, just an attempt to find the specific context for this problem. Please install the follo... | 2013/09/19 | [
"https://wordpress.stackexchange.com/questions/114845",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38181/"
] | I am unable to set the year below 1899 for a post. If i set year below 1899 it is set to the current year automatically.

I have purchased the *Timeline* theme and asked in their support forum. They replied:
>
> This sounds like a limitation created by your hosting... | This is not really an answer, just an attempt to find the specific context for this problem. Please install the following plugin on your site, try to set the three dates and add your result to the second `<pre>` in the table below.
```
/* Plugin Name: WPSE Sysinfo */
add_action( 'admin_footer', 'wpse_sysinfo' );
funct... |
114,898 | <p>I have added a few meta boxes for the posts and pages, so I want to load a js script only on the Create/Edit post and page. How can I do that?
Currently I'm using following but that loads the scripts in all pages in the admin.</p>
<pre><code>function my_meta_boxes() {
add_meta_box("post_meta", "Meta", "post_met... | [
{
"answer_id": 114901,
"author": "Maruti Mohanty",
"author_id": 37890,
"author_profile": "https://wordpress.stackexchange.com/users/37890",
"pm_score": 0,
"selected": false,
"text": "<p>Use admin_enqueue_scripts hook to enqueue scripts to the admin pages and to make it to specific page f... | 2013/09/20 | [
"https://wordpress.stackexchange.com/questions/114898",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38318/"
] | I have added a few meta boxes for the posts and pages, so I want to load a js script only on the Create/Edit post and page. How can I do that?
Currently I'm using following but that loads the scripts in all pages in the admin.
```
function my_meta_boxes() {
add_meta_box("post_meta", "Meta", "post_meta", "post", "n... | We can improve a little bit with :
```
function specific_enqueue($hook_suffix) {
if( 'post.php' == $hook_suffix || 'post-new.php' == $hook_suffix ) {
wp_enqueue_script( 'custom_js', get_template_directory_uri() . '/inc/meta/custom.js', array( 'jquery' ));
wp_enqueue_style( 'custom_css', get_template_direc... |
114,908 | <p>How to lock a post or page from editing or deleting but can be viewed on site? I am not able to lock a post, I read several articles but can't find my answer.</p>
<p>Any help?</p>
| [
{
"answer_id": 114911,
"author": "Max Yudin",
"author_id": 11761,
"author_profile": "https://wordpress.stackexchange.com/users/11761",
"pm_score": 0,
"selected": false,
"text": "<p>Try <a href=\"http://wordpress.org/plugins/role-scoper/\" rel=\"nofollow\">Role Scoper</a> plugin.</p>\n\n<... | 2013/09/20 | [
"https://wordpress.stackexchange.com/questions/114908",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38212/"
] | How to lock a post or page from editing or deleting but can be viewed on site? I am not able to lock a post, I read several articles but can't find my answer.
Any help? | You can use the [`'wp_insert_post_data'`](http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_insert_post_data) filter to set the data being updated to the ones post has right now:
```
add_filter('wp_insert_post_data', 'prevent_post_edit', 99, 2);
prevent_post_edit ($data, $postarr) {
if ( ! isset($postarr['I... |