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
140,439
<p>okay so I'm using the following code to get my links...</p> <pre><code>&lt;?php wp_nav_menu( array('theme_location' =&gt; 'primary', 'container' =&gt; '', 'menu_class' =&gt; 'mainnav') ); ?&gt; </code></pre> <p>This is my CSS for the nav...</p> <pre><code>.mainnav a { font-family: gooddog_plainregular, Arial,...
[ { "answer_id": 140812, "author": "Howdy_McGee", "author_id": 7355, "author_profile": "https://wordpress.stackexchange.com/users/7355", "pm_score": 2, "selected": false, "text": "<p>Here's a function I use to add a first / last class to <code>wp_nav_menu()</code> items:</p>\n\n<pre><code>...
2014/04/06
[ "https://wordpress.stackexchange.com/questions/140439", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49878/" ]
okay so I'm using the following code to get my links... ``` <?php wp_nav_menu( array('theme_location' => 'primary', 'container' => '', 'menu_class' => 'mainnav') ); ?> ``` This is my CSS for the nav... ``` .mainnav a { font-family: gooddog_plainregular, Arial, sans-serif; font-size: 30px; color: #ffea00...
Here's a function I use to add a first / last class to `wp_nav_menu()` items: ``` function add_first_and_last($items) { $items[1]->classes[] = 'first'; $items[count($items)]->classes[] = 'last'; return $items; } add_filter('wp_nav_menu_objects', 'add_first_and_last'); ``` [Developer Resources - `wp_nav_m...
140,466
<p>I'm working on a custom shortcode:</p> <p><code>[abuzz-store slug="woolworths" fields="description,level,phone" more="true"]</code></p> <p>The shortcode is working correctly on the website frontend. However, I can no longer save edits to pages in wp-admin. Various PHP errors are thrown from trying to execute the s...
[ { "answer_id": 140812, "author": "Howdy_McGee", "author_id": 7355, "author_profile": "https://wordpress.stackexchange.com/users/7355", "pm_score": 2, "selected": false, "text": "<p>Here's a function I use to add a first / last class to <code>wp_nav_menu()</code> items:</p>\n\n<pre><code>...
2014/04/07
[ "https://wordpress.stackexchange.com/questions/140466", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50012/" ]
I'm working on a custom shortcode: `[abuzz-store slug="woolworths" fields="description,level,phone" more="true"]` The shortcode is working correctly on the website frontend. However, I can no longer save edits to pages in wp-admin. Various PHP errors are thrown from trying to execute the shortcode outside of the prop...
Here's a function I use to add a first / last class to `wp_nav_menu()` items: ``` function add_first_and_last($items) { $items[1]->classes[] = 'first'; $items[count($items)]->classes[] = 'last'; return $items; } add_filter('wp_nav_menu_objects', 'add_first_and_last'); ``` [Developer Resources - `wp_nav_m...
140,488
<p>How would I count the columns of a custom <code>WPDB</code> query?</p> <p>This does work although I need a different kind of output:</p> <pre><code>$sql_assoc = "SELECT * FROM test"; $num_cols = count((array) current($sql_assoc)); echo $num_cols; OUTPUT: 47 </code></pre> <p>But what I would want is every <cod...
[ { "answer_id": 142893, "author": "David H", "author_id": 48416, "author_profile": "https://wordpress.stackexchange.com/users/48416", "pm_score": 1, "selected": true, "text": "<p>This is not possible.</p>\n\n<p>I instead created functions to execute count queries.</p>\n" }, { "ans...
2014/04/07
[ "https://wordpress.stackexchange.com/questions/140488", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48416/" ]
How would I count the columns of a custom `WPDB` query? This does work although I need a different kind of output: ``` $sql_assoc = "SELECT * FROM test"; $num_cols = count((array) current($sql_assoc)); echo $num_cols; OUTPUT: 47 ``` But what I would want is every `column`+the total as output, like so: `4712345...
This is not possible. I instead created functions to execute count queries.
140,502
<p>I'm trying to print the posts' parent title on the page as well as the post title for that page. This is how my content-page.php template currently renders the page title.</p> <pre><code>the_title( '&lt;header class="entry-header"&gt;&lt;h1 class="entry-title"&gt;', '&lt;/h1&gt;&lt;/header&gt;&lt;!-- .entry-header ...
[ { "answer_id": 140504, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": false, "text": "<p>You can just add a check:</p>\n\n<pre><code>if ( ! empty ( $post-&gt;post_parent ) )\n{\n $parent_title = get_the_...
2014/04/07
[ "https://wordpress.stackexchange.com/questions/140502", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14355/" ]
I'm trying to print the posts' parent title on the page as well as the post title for that page. This is how my content-page.php template currently renders the page title. ``` the_title( '<header class="entry-header"><h1 class="entry-title">', '</h1></header><!-- .entry-header -->' ); ``` I realise I can retrieve th...
You can just add a check: ``` if ( ! empty ( $post->post_parent ) ) { $parent_title = get_the_title($post->post_parent); echo "<h1>$parent_title</h1>"; } ``` or use `setup_postdata()`: ``` setup_postdata( $post->post_parent ); the_title( /* arguments here*/ ); wp_reset_postdata(); ```
140,513
<p>I am working on a voting system in Wordpress. I first made it with <code>GET</code> requests but someone told me <a href="https://stackoverflow.com/questions/22882095/php-remove-get-requests-from-url">you should not use <code>GET</code> for this</a>, So I started working with AJAX to update custom fields/meta values...
[ { "answer_id": 140523, "author": "passatgt", "author_id": 8038, "author_profile": "https://wordpress.stackexchange.com/users/8038", "pm_score": 3, "selected": true, "text": "<p>Couple of things:</p>\n\n<p>1: When you include the script after jquery, localise it using the <a href=\"http:/...
2014/04/07
[ "https://wordpress.stackexchange.com/questions/140513", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25834/" ]
I am working on a voting system in Wordpress. I first made it with `GET` requests but someone told me [you should not use `GET` for this](https://stackoverflow.com/questions/22882095/php-remove-get-requests-from-url), So I started working with AJAX to update custom fields/meta values, after reading [this article](https...
Couple of things: 1: When you include the script after jquery, localise it using the [wp\_localize\_script](http://codex.wordpress.org/Function_Reference/wp_localize_script) function: ``` $nonce = wp_create_nonce("vote_nonce"); $yourscript_info = array( 'ajaxurl' => admin_url( 'admin-ajax.php'), 'nonce' => $n...
140,516
<p>It's seemingly simple, I have this loop which should loads posts from, and including the current post.</p> <pre><code>&lt;?php $categories = get_the_category(); foreach( $categories as $category ) { $catID[] = $category-&gt;cat_ID; } $args = array( 'category__in' = &gt; $catID, 'category__not_in' = &gt; ...
[ { "answer_id": 140519, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 3, "selected": true, "text": "<h1>Edit 3</h1>\n\n<p>Now, combine Edits 1 and 2:</p>\n\n<pre><code>'date_query' = &gt; array(\n array(\n ...
2014/04/07
[ "https://wordpress.stackexchange.com/questions/140516", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35858/" ]
It's seemingly simple, I have this loop which should loads posts from, and including the current post. ``` <?php $categories = get_the_category(); foreach( $categories as $category ) { $catID[] = $category->cat_ID; } $args = array( 'category__in' = > $catID, 'category__not_in' = > 1, 'posts_per_page' = ...
Edit 3 ====== Now, combine Edits 1 and 2: ``` 'date_query' = > array( array( 'before' = > strtotime( get_the_date() ), 'inclusive' = > true, ) ) ``` Edit 2 ====== You don't have your `inclusive` parameter inside the correct array. Change this: ``` 'date_query' = > array( array( ...
140,547
<p>I'm trying to get the attachments of a specific term (in its archive page). But the results are showing the resulting images 5 times instead of one.</p> <p>I have multiple loops in this page - one to show related posts, another to show related products (custom post), and this one to show related images. Custom post...
[ { "answer_id": 140519, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 3, "selected": true, "text": "<h1>Edit 3</h1>\n\n<p>Now, combine Edits 1 and 2:</p>\n\n<pre><code>'date_query' = &gt; array(\n array(\n ...
2014/04/07
[ "https://wordpress.stackexchange.com/questions/140547", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50050/" ]
I'm trying to get the attachments of a specific term (in its archive page). But the results are showing the resulting images 5 times instead of one. I have multiple loops in this page - one to show related posts, another to show related products (custom post), and this one to show related images. Custom posts and post...
Edit 3 ====== Now, combine Edits 1 and 2: ``` 'date_query' = > array( array( 'before' = > strtotime( get_the_date() ), 'inclusive' = > true, ) ) ``` Edit 2 ====== You don't have your `inclusive` parameter inside the correct array. Change this: ``` 'date_query' = > array( array( ...
140,550
<p>I am dealing with a Wordpress setup which has 2 widget areas. One seems to be breaking the page, and I want to remove it.</p> <p>Here is the screenshot of my widget setup </p> <p><img src="https://i.stack.imgur.com/i5vyT.png" alt="enter image description here"></p> <p>How can I remove the Main Widget Area without...
[ { "answer_id": 140553, "author": "gmazzap", "author_id": 35541, "author_profile": "https://wordpress.stackexchange.com/users/35541", "pm_score": 3, "selected": true, "text": "<p>No, is not possible, not in 99% of cases.</p>\n\n<p>Widget areas are added with a <a href=\"http://codex.wordp...
2014/04/07
[ "https://wordpress.stackexchange.com/questions/140550", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34846/" ]
I am dealing with a Wordpress setup which has 2 widget areas. One seems to be breaking the page, and I want to remove it. Here is the screenshot of my widget setup ![enter image description here](https://i.stack.imgur.com/i5vyT.png) How can I remove the Main Widget Area without editing any code? Is that possible? ...
No, is not possible, not in 99% of cases. Widget areas are added with a [`register_sidebar`](http://codex.wordpress.org/Function_Reference/register_sidebar) call in a php file. Until WordPress read that line, the widget area is registered. So, the the easiest and always available way to prevent a widget area is regis...
140,557
<p>I am working on a custom widget which displays posts from a selected taxonomy (category or tag). This widget contains a textbox which the user enters an ID of a taxonomy (category or tag) to exclude from posts. This ID can vary from widget to widget as multiple instances of this widget will appear on the same page e...
[ { "answer_id": 140553, "author": "gmazzap", "author_id": 35541, "author_profile": "https://wordpress.stackexchange.com/users/35541", "pm_score": 3, "selected": true, "text": "<p>No, is not possible, not in 99% of cases.</p>\n\n<p>Widget areas are added with a <a href=\"http://codex.wordp...
2014/04/07
[ "https://wordpress.stackexchange.com/questions/140557", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49947/" ]
I am working on a custom widget which displays posts from a selected taxonomy (category or tag). This widget contains a textbox which the user enters an ID of a taxonomy (category or tag) to exclude from posts. This ID can vary from widget to widget as multiple instances of this widget will appear on the same page excl...
No, is not possible, not in 99% of cases. Widget areas are added with a [`register_sidebar`](http://codex.wordpress.org/Function_Reference/register_sidebar) call in a php file. Until WordPress read that line, the widget area is registered. So, the the easiest and always available way to prevent a widget area is regis...
140,565
<p>So I was looking to create a multi site for a clients since the goal is to have the same branded theme on several sub domains to deal with different countries (e.g. mysite.com, usa.mysite.com, canada.mysite.com) where the root site was basically a map to pick our countries site. After reading all about wordpress mul...
[ { "answer_id": 140553, "author": "gmazzap", "author_id": 35541, "author_profile": "https://wordpress.stackexchange.com/users/35541", "pm_score": 3, "selected": true, "text": "<p>No, is not possible, not in 99% of cases.</p>\n\n<p>Widget areas are added with a <a href=\"http://codex.wordp...
2014/04/07
[ "https://wordpress.stackexchange.com/questions/140565", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35153/" ]
So I was looking to create a multi site for a clients since the goal is to have the same branded theme on several sub domains to deal with different countries (e.g. mysite.com, usa.mysite.com, canada.mysite.com) where the root site was basically a map to pick our countries site. After reading all about wordpress multi ...
No, is not possible, not in 99% of cases. Widget areas are added with a [`register_sidebar`](http://codex.wordpress.org/Function_Reference/register_sidebar) call in a php file. Until WordPress read that line, the widget area is registered. So, the the easiest and always available way to prevent a widget area is regis...
140,572
<p>I try to split my navigation into 3 single navigation bars (level 1, level 2 and level3+). Three because they're separated over the site and they should only appear depending on the current page.</p> <pre><code>-0-------1--------2-------3+- level/depth Home | |\___ Lobby | |\___ Projects | |\___ Project ...
[ { "answer_id": 140588, "author": "nonsensation", "author_id": 50053, "author_profile": "https://wordpress.stackexchange.com/users/50053", "pm_score": 3, "selected": true, "text": "<p>I think I got the answer:</p>\n\n<pre><code>function my_nav_menu( $args = array() )\n{\n $echo = isset...
2014/04/07
[ "https://wordpress.stackexchange.com/questions/140572", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50053/" ]
I try to split my navigation into 3 single navigation bars (level 1, level 2 and level3+). Three because they're separated over the site and they should only appear depending on the current page. ``` -0-------1--------2-------3+- level/depth Home | |\___ Lobby | |\___ Projects | |\___ Project A | | ...
I think I got the answer: ``` function my_nav_menu( $args = array() ) { $echo = isset( $args['echo'] ) ? (bool)( $args['echo'] ) : true; $args['echo'] = false; add_filter( 'wp_nav_menu_objects' , 'my_filter_nav_menu' , 100 , 2 ); $menu = wp_nav_menu( $args ); remove_filter( 'wp_nav_menu_objects...
140,598
<p>I'm using this code to use custom post types like regular post:</p> <pre><code>add_action( 'pre_get_posts', 'add_my_post_types_to_query' ); function add_my_post_types_to_query( $query ) { if ( is_home() &amp;&amp; $query-&gt;is_main_query() ) $query-&gt;set( 'post_type', array( 'post', 'miss_behave', 'emily_da...
[ { "answer_id": 140588, "author": "nonsensation", "author_id": 50053, "author_profile": "https://wordpress.stackexchange.com/users/50053", "pm_score": 3, "selected": true, "text": "<p>I think I got the answer:</p>\n\n<pre><code>function my_nav_menu( $args = array() )\n{\n $echo = isset...
2014/04/08
[ "https://wordpress.stackexchange.com/questions/140598", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74495/" ]
I'm using this code to use custom post types like regular post: ``` add_action( 'pre_get_posts', 'add_my_post_types_to_query' ); function add_my_post_types_to_query( $query ) { if ( is_home() && $query->is_main_query() ) $query->set( 'post_type', array( 'post', 'miss_behave', 'emily_davies','gemma_patel','poppy_s...
I think I got the answer: ``` function my_nav_menu( $args = array() ) { $echo = isset( $args['echo'] ) ? (bool)( $args['echo'] ) : true; $args['echo'] = false; add_filter( 'wp_nav_menu_objects' , 'my_filter_nav_menu' , 100 , 2 ); $menu = wp_nav_menu( $args ); remove_filter( 'wp_nav_menu_objects...
140,606
<p>I am working on a project where I need jQuery for. I added this to my functions, and the scripts are loaded in my header if I watch my page source, but jQuery doesn't work. What am I doing wrong?</p> <pre><code>function stn_script_enqueuer() { wp_register_script( 'ajax-vote', get_template_directory_uri() . '/j...
[ { "answer_id": 140588, "author": "nonsensation", "author_id": 50053, "author_profile": "https://wordpress.stackexchange.com/users/50053", "pm_score": 3, "selected": true, "text": "<p>I think I got the answer:</p>\n\n<pre><code>function my_nav_menu( $args = array() )\n{\n $echo = isset...
2014/04/08
[ "https://wordpress.stackexchange.com/questions/140606", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25834/" ]
I am working on a project where I need jQuery for. I added this to my functions, and the scripts are loaded in my header if I watch my page source, but jQuery doesn't work. What am I doing wrong? ``` function stn_script_enqueuer() { wp_register_script( 'ajax-vote', get_template_directory_uri() . '/js/ajax-vote.js...
I think I got the answer: ``` function my_nav_menu( $args = array() ) { $echo = isset( $args['echo'] ) ? (bool)( $args['echo'] ) : true; $args['echo'] = false; add_filter( 'wp_nav_menu_objects' , 'my_filter_nav_menu' , 100 , 2 ); $menu = wp_nav_menu( $args ); remove_filter( 'wp_nav_menu_objects...
140,614
<p>I want to replace the <code>sidebar-2</code> in the twentyforteen theme with a custom sidebar based on a conditional statement for CPT. So if the page is showing a certain custom post type then show my custom sidebar, else just show the default sidebar.</p> <p>I want to do this without changing the theme or using a...
[ { "answer_id": 140621, "author": "Brad Dalton", "author_id": 9884, "author_profile": "https://wordpress.stackexchange.com/users/9884", "pm_score": 0, "selected": false, "text": "<p>I wouldn't use <a href=\"https://codex.wordpress.org/Function_Reference/unregister_sidebar\" rel=\"nofollow...
2014/04/08
[ "https://wordpress.stackexchange.com/questions/140614", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23620/" ]
I want to replace the `sidebar-2` in the twentyforteen theme with a custom sidebar based on a conditional statement for CPT. So if the page is showing a certain custom post type then show my custom sidebar, else just show the default sidebar. I want to do this without changing the theme or using a child theme (i.e. pu...
I have figured this out. The trick is to use the `get_sidebar` hook and run some conditionals to check if we're on a CPT page (archive or singular or cpt taxonomy archive) and if the sidebar we've hooked into is the one we want to replace (`$sidebar == 'content'`). If these conditionals are met we unregister `sidebar-...
140,639
<p>In my <code>functions.php</code> I have the following:</p> <p><code>add_theme_support( 'post-thumbnails', 'html5', array( 'comment-list', 'comment-form', 'search-form' ) );</code></p> <p>…which in WP 3.8.1 disables e.g. featured image (i.e. <code>post-thumbnails</code>).</p> <p>My question is how to properly form...
[ { "answer_id": 140642, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 3, "selected": true, "text": "<p>You need to use one <code>add_theme_support()</code> call for each feature. <a href=\"http://codex.wordpres...
2014/04/08
[ "https://wordpress.stackexchange.com/questions/140639", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8243/" ]
In my `functions.php` I have the following: `add_theme_support( 'post-thumbnails', 'html5', array( 'comment-list', 'comment-form', 'search-form' ) );` …which in WP 3.8.1 disables e.g. featured image (i.e. `post-thumbnails`). My question is how to properly format all these support items in the `add_theme_support` fun...
You need to use one `add_theme_support()` call for each feature. [Per the Codex](http://codex.wordpress.org/Function_Reference/add_theme_support), the proper function call is: ``` add_theme_support( $feature, $arguments ); ```
140,651
<p>I wanted to replace the wordpress logo which is displayed on login screen with some custom text. </p> <p>Here is the code what I tried so far:</p> <pre><code>function my_custom_logo() { echo '&lt;style type="text/css"&gt; #header-logo { background-image: url('.get_bloginfo('template_directory').'/images/wp-logo.p...
[ { "answer_id": 140654, "author": "Keshav Kalra", "author_id": 48303, "author_profile": "https://wordpress.stackexchange.com/users/48303", "pm_score": -1, "selected": false, "text": "<p>It's simple </p>\n\n<pre><code>function my_custom_logo() {\necho '&lt;script&gt;jQuery(\"#header-logo\"...
2014/04/08
[ "https://wordpress.stackexchange.com/questions/140651", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31835/" ]
I wanted to replace the wordpress logo which is displayed on login screen with some custom text. Here is the code what I tried so far: ``` function my_custom_logo() { echo '<style type="text/css"> #header-logo { background-image: url('.get_bloginfo('template_directory').'/images/wp-logo.png) !important; }'; } add_ac...
You will first need to remove the wordpress logo from the login screen. The wordpress logo is added by css, so you will need to change the css and hook that to the `login_enqueue_scripts` action hook ``` function my_login_logo() { ?> <style type="text/css"> body.login div#login h1 a { backgroun...
140,669
<p>We're scoping an upcoming project that will require the development of a large php web application within an existing wordpress site - this is for our use only and we've no intention of trying to package it for other users; so interoperability isn't really a concern as long as we can continue to apply WordPress upda...
[ { "answer_id": 140673, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 4, "selected": true, "text": "<h1>Custom implementation vs. Standard API usage</h1>\n\n<p>Using the WP AJAX API is the way to go. First off, you get...
2014/04/08
[ "https://wordpress.stackexchange.com/questions/140669", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50104/" ]
We're scoping an upcoming project that will require the development of a large php web application within an existing wordpress site - this is for our use only and we've no intention of trying to package it for other users; so interoperability isn't really a concern as long as we can continue to apply WordPress updates...
Custom implementation vs. Standard API usage ============================================ Using the WP AJAX API is the way to go. First off, you get access to the complete set of WP APIs, you can leverage standard jQuery `$.ajax()` and similar API calls and you are running standard conform, gaining access to all knowl...
140,685
<p>Can somebody give me an explanation on the differences between the 4 different built in RSS Feeds and why / when I should choose one over the other? Why does WordPress incorporate 4 different ones instead of focusing on 1 universal one? The feeds include:</p> <p>1) RDF/RSS 1.0 feed </p> <p>2) RSS 0.92 feed</p> <p...
[ { "answer_id": 140686, "author": "Ray Mitchell", "author_id": 2709, "author_profile": "https://wordpress.stackexchange.com/users/2709", "pm_score": 2, "selected": false, "text": "<p>The various versions of RSS contain increasingly complex information, with the RSS 2.* being the most up t...
2014/04/08
[ "https://wordpress.stackexchange.com/questions/140685", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7355/" ]
Can somebody give me an explanation on the differences between the 4 different built in RSS Feeds and why / when I should choose one over the other? Why does WordPress incorporate 4 different ones instead of focusing on 1 universal one? The feeds include: 1) RDF/RSS 1.0 feed 2) RSS 0.92 feed 3) RSS 2.0 feed 4) Ato...
Feeds are not stored, WordPress generate them on request. That means that even if WordPress *can* generate 4 type of feed, that does not affect in any way performance, but gives the *possibility* to users to choose a format they like according to reader they are using: is not WordPress fault if there are different type...
140,692
<p>I'm working on a website with a search feature that allows users to search through a lot of post meta. There is a specific search pattern that I would like to forcibly return no results for. The WP_Query technically will find results in the database, but I'd like to override that somehow to force it to return no res...
[ { "answer_id": 140701, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>Curiously there is no clean/explicit way to short circuit <code>WP_Query</code>.</p>\n\n<p>If it's <em>main</em> qu...
2014/04/08
[ "https://wordpress.stackexchange.com/questions/140692", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/44937/" ]
I'm working on a website with a search feature that allows users to search through a lot of post meta. There is a specific search pattern that I would like to forcibly return no results for. The WP\_Query technically will find results in the database, but I'd like to override that somehow to force it to return no resul...
Try ``` 'post__in' => array(0) ``` Simple and to the point. Update: ``` 'post__in' => empty( $include ) ? [ 0 ] : $include, ```
140,694
<p>I want to write plugin which has the ability to change the start page according to a get parameter:</p> <p>The following code is the full plugin.</p> <pre><code>function GET_Different_Page_on_front_parameter() { if (!session_id()) { session_start(); } if(!($_SESSION['start'])){ $_SESSION['start']=$_GE...
[ { "answer_id": 140701, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>Curiously there is no clean/explicit way to short circuit <code>WP_Query</code>.</p>\n\n<p>If it's <em>main</em> qu...
2014/04/08
[ "https://wordpress.stackexchange.com/questions/140694", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34534/" ]
I want to write plugin which has the ability to change the start page according to a get parameter: The following code is the full plugin. ``` function GET_Different_Page_on_front_parameter() { if (!session_id()) { session_start(); } if(!($_SESSION['start'])){ $_SESSION['start']=$_GET['view']; } ...
Try ``` 'post__in' => array(0) ``` Simple and to the point. Update: ``` 'post__in' => empty( $include ) ? [ 0 ] : $include, ```
140,719
<p>Right now I'm serving up my own custom stylesheet.</p> <pre><code>// register main stylesheet wp_register_style( 'custom-stylesheet', get_stylesheet_directory_uri() . '/library/css/main.css', array(), '', 'all' ); </code></pre> <p>It outputs:</p> <pre><code>&lt;link rel='stylesheet' id='custom-stylesheet-css' hr...
[ { "answer_id": 140722, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": false, "text": "<p>You can filter <code>style_loader_tag</code>. You get the HTML element and the handle as arguments.</p>\n\n<p>Example...
2014/04/08
[ "https://wordpress.stackexchange.com/questions/140719", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50046/" ]
Right now I'm serving up my own custom stylesheet. ``` // register main stylesheet wp_register_style( 'custom-stylesheet', get_stylesheet_directory_uri() . '/library/css/main.css', array(), '', 'all' ); ``` It outputs: ``` <link rel='stylesheet' id='custom-stylesheet-css' href='http://localhost/wp-content/themes/c...
You can filter `style_loader_tag`. You get the HTML element and the handle as arguments. Example ``` add_filter( 'style_loader_tag', function( $html, $handle ) { if ( 'custom-stylesheet' !== $handle ) return $html; return str_replace( " id='$handle-css'", '', $html ); }, 10, 2 ); ``` But really, I...
140,752
<blockquote> <p>Fatal error: Call to undefined function get_header()</p> </blockquote> <p>I can't get this working. I am using twentythirteen default theme shipped with wordpress. I have created a custom template called <code>table.php</code> and I also used <code>&lt;?php template name ?&gt;</code>. This custom tem...
[ { "answer_id": 140850, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 1, "selected": false, "text": "<p>You can't load template files directly. WordPress is not loaded in that context, so you have no access to its func...
2014/04/09
[ "https://wordpress.stackexchange.com/questions/140752", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50139/" ]
> > Fatal error: Call to undefined function get\_header() > > > I can't get this working. I am using twentythirteen default theme shipped with wordpress. I have created a custom template called `table.php` and I also used `<?php template name ?>`. This custom template simply shows up all records in a database. Its...
You can't load template files directly. WordPress is not loaded in that context, so you have no access to its functions. Create a page in WordPress admin, and assign your template to that page, then point your link to that page rather than directly to the template file.
140,770
<p>I'm growing grey hair here. I've tried so many things and yet I can't get a grasp on how to set this up. Found tons of guides but no one goes through all aspects, which are:</p> <ul> <li>A single WP Multisite install that handles several domain based (8 to be exact) sites</li> <li>Site running on Nginx</li> </ul> ...
[ { "answer_id": 227746, "author": "Uncle Iroh", "author_id": 44927, "author_profile": "https://wordpress.stackexchange.com/users/44927", "pm_score": 0, "selected": false, "text": "<p>I don't always outsource my work, but when I do, I hire people in the USA. Have you considered outsourcing...
2014/04/09
[ "https://wordpress.stackexchange.com/questions/140770", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3390/" ]
I'm growing grey hair here. I've tried so many things and yet I can't get a grasp on how to set this up. Found tons of guides but no one goes through all aspects, which are: * A single WP Multisite install that handles several domain based (8 to be exact) sites * Site running on Nginx Following this guide (<https://w...
*I don't have enough reputation for comments and hope I don't get down voted here.* I also use Nginx. Although my set up is a little different to yours the principal should be the same. In your nginx.conf you need to identify the domain names Nginx will handle. For example; ``` http { include /etc/nginx...
140,833
<p>I'm working on a form for filtering a list of posts using custom fields created with the Advanced Custom Fields plugin. Because of the form, I'm using the <code>pre_get_posts</code> action to change the query via GET requests. (following code references are either PHP or dumped from <code>print_r()</code>)</p> <p>I...
[ { "answer_id": 140840, "author": "gmazzap", "author_id": 35541, "author_profile": "https://wordpress.stackexchange.com/users/35541", "pm_score": 1, "selected": false, "text": "<p>If I am correct, you have a field that contain an array, to be clear, something that you can save using:</p>\...
2014/04/09
[ "https://wordpress.stackexchange.com/questions/140833", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50172/" ]
I'm working on a form for filtering a list of posts using custom fields created with the Advanced Custom Fields plugin. Because of the form, I'm using the `pre_get_posts` action to change the query via GET requests. (following code references are either PHP or dumped from `print_r()`) I set the meta\_query like this: ...
The ACF Documentation recommends checking the values individually rather than simultaneously using an array. The following code is from the ACF Documentation for the Checkbox field type: <http://www.advancedcustomfields.com/resources/field-types/checkbox/> ``` /* * Query posts for a checkbox value. * This method u...
140,871
<p>I am having a problem with an if statement which I have now tested many times over.</p> <pre><code> $user_query = new WP_User_Query( array( 'role' =&gt; 'Subscriber' ) ); if ( !empty( $user_query-&gt;results ) ) { foreach ( $user_query-&gt;results as $user ) { echo $user...
[ { "answer_id": 140838, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": true, "text": "<p><code>functions.php</code> unfortunately is very ingrained part of theme load process. If your architecture is flexi...
2014/04/10
[ "https://wordpress.stackexchange.com/questions/140871", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12589/" ]
I am having a problem with an if statement which I have now tested many times over. ``` $user_query = new WP_User_Query( array( 'role' => 'Subscriber' ) ); if ( !empty( $user_query->results ) ) { foreach ( $user_query->results as $user ) { echo $user->province . '<br/>'; /...
`functions.php` unfortunately is very ingrained part of theme load process. If your architecture is flexible enough you should be able to conditionally unhook related bits. Even if it's not — templates give you complete control over page output. You could go as far as completely omitting `wp_head()`/`wp_footer()` call...
140,885
<p>I would like to show the 'Appearance -> Widgets' menu underneath the text field in 'Pages -> new/edit'. Is it possible to take one part of the admin and show it elsewhere?</p> <p>Reading some of the answers, it seems this question get's misunderstood. I'm looking for a way to <strong>show the widgets admin</strong>...
[ { "answer_id": 141022, "author": "Monkey Puzzle", "author_id": 48568, "author_profile": "https://wordpress.stackexchange.com/users/48568", "pm_score": 1, "selected": false, "text": "<p>Yes it is, and this can be a very handy feature. The 'hiding place' for widgets is one of the least int...
2014/04/10
[ "https://wordpress.stackexchange.com/questions/140885", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5828/" ]
I would like to show the 'Appearance -> Widgets' menu underneath the text field in 'Pages -> new/edit'. Is it possible to take one part of the admin and show it elsewhere? Reading some of the answers, it seems this question get's misunderstood. I'm looking for a way to **show the widgets admin** **on the page edit adm...
If I understand well your want to show the widgets adding and removing interface inside a meta box. An easy, -a little dirty- way is using an iframe: ``` function metaboxed_widgets_admin() { if ( ! current_user_can( 'edit_theme_options' ) ) return; add_meta_box('metaboxed_widgets', __('Widgets'), 'metaboxed_widge...
140,896
<p>I've been stuck on a problem for a while now and I can't seem to figure it out. </p> <p>I want to query posts and only display them if their 2 meta values checked contain the ones I have queried. </p> <p>For example:</p> <p>If a post had 123 and 321 then I want them to be displayed. But if it had 123 and 123 then...
[ { "answer_id": 141022, "author": "Monkey Puzzle", "author_id": 48568, "author_profile": "https://wordpress.stackexchange.com/users/48568", "pm_score": 1, "selected": false, "text": "<p>Yes it is, and this can be a very handy feature. The 'hiding place' for widgets is one of the least int...
2014/04/10
[ "https://wordpress.stackexchange.com/questions/140896", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50194/" ]
I've been stuck on a problem for a while now and I can't seem to figure it out. I want to query posts and only display them if their 2 meta values checked contain the ones I have queried. For example: If a post had 123 and 321 then I want them to be displayed. But if it had 123 and 123 then it shouldn't be display...
If I understand well your want to show the widgets adding and removing interface inside a meta box. An easy, -a little dirty- way is using an iframe: ``` function metaboxed_widgets_admin() { if ( ! current_user_can( 'edit_theme_options' ) ) return; add_meta_box('metaboxed_widgets', __('Widgets'), 'metaboxed_widge...
140,900
<p>This may be a duplicate of this question - <a href="https://wordpress.stackexchange.com/questions/40701/changing-the-priority-of-a-custom-taxonomys-metabox">Changing the priority of a custom taxonomy&#39;s metabox</a> but I can't work out how to apply that answer. I'm unsure what my custom taxonomy div label would b...
[ { "answer_id": 140906, "author": "codearachnid", "author_id": 28798, "author_profile": "https://wordpress.stackexchange.com/users/28798", "pm_score": 2, "selected": false, "text": "<p>In your case you can edit the following code to accomplish what you are looking for by assigning the cus...
2014/04/10
[ "https://wordpress.stackexchange.com/questions/140900", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20327/" ]
This may be a duplicate of this question - [Changing the priority of a custom taxonomy's metabox](https://wordpress.stackexchange.com/questions/40701/changing-the-priority-of-a-custom-taxonomys-metabox) but I can't work out how to apply that answer. I'm unsure what my custom taxonomy div label would be and how to get i...
After researching s\_ha\_dum's link and others for a while it seemed like the only way to position meta boxes in between the title and editor fields was to remove and readd the main editor [like this](https://wordpress.stackexchange.com/a/101013/20327), but this feels a bit hacky to me and receives a warning from anoth...
140,901
<p>I let users create posts and upload/attach images to that post via the <strong>frontend</strong>. This works fine. However, when I restrict the access to the Wordpress backend (/wp-admin/) via a code snippet like this one</p> <pre><code>function wpse_11244_restrict_admin() { if ( ! current_user_can( 'manage_opt...
[ { "answer_id": 275234, "author": "J.D.", "author_id": 27757, "author_profile": "https://wordpress.stackexchange.com/users/27757", "pm_score": 1, "selected": false, "text": "<p>First, it is important to consider why you are restricting access to <code>wp-admin</code>. If you are doing thi...
2014/04/10
[ "https://wordpress.stackexchange.com/questions/140901", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48847/" ]
I let users create posts and upload/attach images to that post via the **frontend**. This works fine. However, when I restrict the access to the Wordpress backend (/wp-admin/) via a code snippet like this one ``` function wpse_11244_restrict_admin() { if ( ! current_user_can( 'manage_options' ) ) { wp_die(...
First, it is important to consider why you are restricting access to `wp-admin`. If you are doing this mainly for aesthetic purposes, then the solution provided below is fine. However, if you are doing it because you don't want your users to be able to perform certain functions provided via the back-end, you should be ...
140,913
<p>My website is getting somewhat popular, and with the it's increasing popularity there's an increase in the hackers.</p> <p>Last night I visited my security logs and found that everyday approximately 10 people try to access</p> <pre><code> /?author=1 /?author=2 /?author=3 /?author=4 </code></pre> <p>but I don't...
[ { "answer_id": 140916, "author": "Howdy_McGee", "author_id": 7355, "author_profile": "https://wordpress.stackexchange.com/users/7355", "pm_score": 1, "selected": true, "text": "<p>I understand this isn't exactly what you're looking for but these hackers are most likely bots and redirecti...
2014/04/10
[ "https://wordpress.stackexchange.com/questions/140913", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43423/" ]
My website is getting somewhat popular, and with the it's increasing popularity there's an increase in the hackers. Last night I visited my security logs and found that everyday approximately 10 people try to access ``` /?author=1 /?author=2 /?author=3 /?author=4 ``` but I don't have any of these user IDs, so a...
I understand this isn't exactly what you're looking for but these hackers are most likely bots and redirecting them won't matter at all. I suppose you could modify the below code if you reallllly wanted to but this will redirect anybody looking for an author back to your homepage. ``` RewriteCond %{REQUEST_URI} ^/$ R...
140,934
<p>I need the built-in gallery shortcode to output UL instead of DL. How can I do it? I know I can use the 'post_gallery' filter, but that means almost duplicating the media's gallery_shortcode function. I'd like to find a less 'verbose' solution. </p> <p>Thank you</p>
[ { "answer_id": 140916, "author": "Howdy_McGee", "author_id": 7355, "author_profile": "https://wordpress.stackexchange.com/users/7355", "pm_score": 1, "selected": true, "text": "<p>I understand this isn't exactly what you're looking for but these hackers are most likely bots and redirecti...
2014/04/10
[ "https://wordpress.stackexchange.com/questions/140934", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10381/" ]
I need the built-in gallery shortcode to output UL instead of DL. How can I do it? I know I can use the 'post\_gallery' filter, but that means almost duplicating the media's gallery\_shortcode function. I'd like to find a less 'verbose' solution. Thank you
I understand this isn't exactly what you're looking for but these hackers are most likely bots and redirecting them won't matter at all. I suppose you could modify the below code if you reallllly wanted to but this will redirect anybody looking for an author back to your homepage. ``` RewriteCond %{REQUEST_URI} ^/$ R...
140,956
<p>I have a problem to display pagination using <code>WP_Query</code>. I've created a custom page, code below:</p> <pre><code>&lt;?php /* Template name: Models */ ?&gt; &lt;?php get_header(); ?&gt; &lt;?php the_post();?&gt; &lt;link rel="stylesheet" href="&lt;?php echo get_template_directory_uri(); ?&gt;/css/mod...
[ { "answer_id": 140959, "author": "Dln", "author_id": 50220, "author_profile": "https://wordpress.stackexchange.com/users/50220", "pm_score": -1, "selected": false, "text": "<p>You're using the argument <code>'posts_per_page' =&gt; '4'</code> in the <code>WP_Query</code>.</p>\n\n<p>That i...
2014/04/10
[ "https://wordpress.stackexchange.com/questions/140956", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40659/" ]
I have a problem to display pagination using `WP_Query`. I've created a custom page, code below: ``` <?php /* Template name: Models */ ?> <?php get_header(); ?> <?php the_post();?> <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/models.css"> <link rel="stylesheet" href="<?php ...
Thanks Pat J I'have got solution now: ``` <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?> <?php $offset = ($paged - 1) * 4;?> <?php $kat = get_field('kategory');?> <?php $query = new WP_Query(array('offset' => $offset,'post_type' => 'modelki', 'taxonomy' => $kat, 'posts_per_page' => '4')); ...
141,001
<p>My mail function is not working. When I submit form it says mail sent. But not receiving. I tried echo if the mail sent. It is also working. What is the issue here? Anything with mail function ?</p> <pre><code>&lt;?php $name = $_POST[ 'cuf_sender' . $n ]; $email = $_POST[ 'cuf_email' . $n ]; $subject = $this-&...
[ { "answer_id": 141007, "author": "Rajeev Vyas", "author_id": 6961, "author_profile": "https://wordpress.stackexchange.com/users/6961", "pm_score": 1, "selected": false, "text": "<p>You are passing <code>$email</code> where there should be attachments. Look at <a href=\"http://codex.wordp...
2014/04/11
[ "https://wordpress.stackexchange.com/questions/141001", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/68591/" ]
My mail function is not working. When I submit form it says mail sent. But not receiving. I tried echo if the mail sent. It is also working. What is the issue here? Anything with mail function ? ``` <?php $name = $_POST[ 'cuf_sender' . $n ]; $email = $_POST[ 'cuf_email' . $n ]; $subject = $this->o['subpre'] . ' '...
You are passing `$email` where there should be attachments. Look at [wp\_mail](http://codex.wordpress.org/Function_Reference/wp_mail) arguments. Also you have not defined `$to` variable which in your case i assume should be `$email`. Try this, ``` $name = $_POST['cuf_sender'.$n]; $email = $_POST['cuf_email'.$...
141,037
<p>I am not sure if it is possible or not. </p> <p>Can i use <code>wp_localize_script</code> with <code>mce_external_plugins</code> filter? </p> <p>I want to send a variable to the tinymce plugin script. For Example: </p> <pre><code>add_filter( "mce_external_plugins", array( &amp;$this, 'add_test_plugin' ) ); pub...
[ { "answer_id": 141042, "author": "Douglas.Sesar", "author_id": 19945, "author_profile": "https://wordpress.stackexchange.com/users/19945", "pm_score": 1, "selected": false, "text": "<p>If I understand correctly; you just need to make a Javascript variable available to testing.js.</p>\n\n...
2014/04/11
[ "https://wordpress.stackexchange.com/questions/141037", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13331/" ]
I am not sure if it is possible or not. Can i use `wp_localize_script` with `mce_external_plugins` filter? I want to send a variable to the tinymce plugin script. For Example: ``` add_filter( "mce_external_plugins", array( &$this, 'add_test_plugin' ) ); public function add_test_plugin( $plugin_array ){ glob...
If I understand correctly; you just need to make a Javascript variable available to testing.js. I think it would be just as useful to send the variable with jQuery, as that would be loaded prior to TinyMCE anyway: ``` add_action('wp_enqueue_scripts', 'YOUR_NAME_scripts'); //back end function YOUR_NAME_scripts( $hook...
141,040
<p>I have 2 WP_Editors, 1 is the main editor I use for content and the 2nd is an editor I use for the user to insert videos and any extra content describing the video. My question is, is there an easy way to pull the video URL before (during or after) oEmbed grabs it? I've tried to use a <code>preg_match</code> but fee...
[ { "answer_id": 141041, "author": "Douglas.Sesar", "author_id": 19945, "author_profile": "https://wordpress.stackexchange.com/users/19945", "pm_score": 1, "selected": false, "text": "<p>Maybe you should just add a custom field to accept the url itself, in stead of the wp_editor textarea; ...
2014/04/11
[ "https://wordpress.stackexchange.com/questions/141040", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7355/" ]
I have 2 WP\_Editors, 1 is the main editor I use for content and the 2nd is an editor I use for the user to insert videos and any extra content describing the video. My question is, is there an easy way to pull the video URL before (during or after) oEmbed grabs it? I've tried to use a `preg_match` but feel that there'...
Maybe you should just add a custom field to accept the url itself, in stead of the wp\_editor textarea; then append the video embed after you work with the input. Let me know if you need any help setting that up. OR: You could add a separete textarea to accept just comma separated or line-break separated urls (Becau...
141,050
<p>Lots of Googling has still not yielded a solution. Here is the problem:</p> <p>I have created a custom Wordpress shortcode to use inside my Thesis theme. The goal of the shortcode is to allow users to wrap content on a page/post in Schema markup tags. My code is below:</p> <pre><code>function articlesection_rs_sho...
[ { "answer_id": 141382, "author": "Kirill M", "author_id": 50270, "author_profile": "https://wordpress.stackexchange.com/users/50270", "pm_score": 1, "selected": false, "text": "<p>There was some weird issue with how Wordpress was handling line-breaks and auto styling between the shortcod...
2014/04/11
[ "https://wordpress.stackexchange.com/questions/141050", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50270/" ]
Lots of Googling has still not yielded a solution. Here is the problem: I have created a custom Wordpress shortcode to use inside my Thesis theme. The goal of the shortcode is to allow users to wrap content on a page/post in Schema markup tags. My code is below: ``` function articlesection_rs_shortcode($atts, $conten...
There was some weird issue with how Wordpress was handling line-breaks and auto styling between the shortcodes. After some more playing around was able to eliminate the issue. Very finicky system...
141,055
<p>I'm looking to set up pagination on my single.php file so I can have my infinite scroll function correctly. I know that pagination can be put on a single post but I somehow need to make the single.php page be able to have an appended variable on the URL. What I mean is if I have this URL:</p> <pre><code>http://www....
[ { "answer_id": 141217, "author": "Hardeep Asrani", "author_id": 33233, "author_profile": "https://wordpress.stackexchange.com/users/33233", "pm_score": 1, "selected": false, "text": "<p>Add <code>&lt;!--nextpage--&gt;</code> in your post editor to split your post.</p>\n" }, { "an...
2014/04/11
[ "https://wordpress.stackexchange.com/questions/141055", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16856/" ]
I'm looking to set up pagination on my single.php file so I can have my infinite scroll function correctly. I know that pagination can be put on a single post but I somehow need to make the single.php page be able to have an appended variable on the URL. What I mean is if I have this URL: ``` http://www.example.com/po...
Add `<!--nextpage-->` in your post editor to split your post.
141,059
<p>Let's say I have a custom post type called <code>Film</code>, with a repeater field called <code>Showings</code>, with fields <code>start_datetime</code> and <code>discount</code>.</p> <p>I need to make a query for those Films that have at least one showing that is in the next week and (this showing) has also a dis...
[ { "answer_id": 292576, "author": "Maroun Melhem", "author_id": 83054, "author_profile": "https://wordpress.stackexchange.com/users/83054", "pm_score": 2, "selected": false, "text": "<p>I know this is an old question, but I thought I'd post the answer in case anybody else is facing the sa...
2014/04/12
[ "https://wordpress.stackexchange.com/questions/141059", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48313/" ]
Let's say I have a custom post type called `Film`, with a repeater field called `Showings`, with fields `start_datetime` and `discount`. I need to make a query for those Films that have at least one showing that is in the next week and (this showing) has also a discount. The query I have now, retrieves the films with...
I know this is an old question, but I thought I'd post the answer in case anybody else is facing the same problem. **functions.php**: ``` function add_cond_to_where( $where ) { //Replace showings_$ with repeater_slug_$ $where = str_replace("meta_key = 'showings_$", "meta_key LIKE 'showings_%", $w...
141,074
<p>In an attempt to use the custom post type, after having registered a brand new CPT I have duplicated both the single and the archive pages appending the "-posttype" bit as specified in the register_post_type function.</p> <p>However, if I try to load a single post or the archive page, both the pages are not loaded...
[ { "answer_id": 141080, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 1, "selected": false, "text": "<p>I have copied your CPT code to my localhost. I had to add <code>register_post_type( 'facebook', $args )...
2014/04/12
[ "https://wordpress.stackexchange.com/questions/141074", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26216/" ]
In an attempt to use the custom post type, after having registered a brand new CPT I have duplicated both the single and the archive pages appending the "-posttype" bit as specified in the register\_post\_type function. However, if I try to load a single post or the archive page, both the pages are not loaded. I can't...
Try updating permalinks in settings. If that doesn't work please provide the code for your register\_posttype function. > > both the pages are not loaded > > > ...meaning you get 404 errors, or the correct content loads but in the wrong templates? when new post types are added, you will get 404 errors using prett...
141,105
<p>I'm working on a site where users are able to publish posts with custom fields associated with them. I want to display meta values from all posts, and include which user created the post where the meta value is coming from.</p> <p>So far I have been able to display all meta values from all posts. My code:</p> <pre...
[ { "answer_id": 141080, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 1, "selected": false, "text": "<p>I have copied your CPT code to my localhost. I had to add <code>register_post_type( 'facebook', $args )...
2014/04/12
[ "https://wordpress.stackexchange.com/questions/141105", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50121/" ]
I'm working on a site where users are able to publish posts with custom fields associated with them. I want to display meta values from all posts, and include which user created the post where the meta value is coming from. So far I have been able to display all meta values from all posts. My code: ``` function get_m...
Try updating permalinks in settings. If that doesn't work please provide the code for your register\_posttype function. > > both the pages are not loaded > > > ...meaning you get 404 errors, or the correct content loads but in the wrong templates? when new post types are added, you will get 404 errors using prett...
141,125
<p>Here is my excerpt code.</p> <pre><code>// Generate custom excerpt length function wpbx_excerpt_length($length) { return 300; } add_filter('excerpt_length', 'wpbx_excerpt_length'); </code></pre> <p>How do I allow html like <code>&lt;a&gt; &lt;b&gt; &lt;i&gt; &lt;br&gt;</code></p>
[ { "answer_id": 141136, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 8, "selected": true, "text": "<p><strong>COMPLETE GUIDE TO EXCERPTS</strong></p>\n<p>I've recently answered a few questions regarding exc...
2014/04/12
[ "https://wordpress.stackexchange.com/questions/141125", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32447/" ]
Here is my excerpt code. ``` // Generate custom excerpt length function wpbx_excerpt_length($length) { return 300; } add_filter('excerpt_length', 'wpbx_excerpt_length'); ``` How do I allow html like `<a> <b> <i> <br>`
**COMPLETE GUIDE TO EXCERPTS** I've recently answered a few questions regarding excerpts, so I'm going to give a detailed explanation covering as much as I can. **PREFACE** There seems to be a couple of questions arising from this answer on where the code should go, and the answer is, it is really up to you and how ...
141,162
<p>I know that the general advice to global variables is to not use them at all. Still, when doing something with the Wordpress database, it is required to do <code>global $wpdb;</code> to access the methods Wordpress provides for interacting with the database.</p> <p>Now I've written a small plugin that introduces se...
[ { "answer_id": 141164, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 2, "selected": false, "text": "<p>Globalizing WordPress-defined vars is not the same as creating your own global variables. In the former, you have ...
2014/04/13
[ "https://wordpress.stackexchange.com/questions/141162", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12580/" ]
I know that the general advice to global variables is to not use them at all. Still, when doing something with the Wordpress database, it is required to do `global $wpdb;` to access the methods Wordpress provides for interacting with the database. Now I've written a small plugin that introduces several functions that ...
A convenient way to use `$wpdb` in plugins, with custom tables and custom functions is write a class or a couple of functions that get the wp object, and configure it. An example: ``` /* Return global wpdb aready setup with custom tables */ my_plugin_get_db( wpdb $wpdb = NULL ) { static $db; if ( is_null($db) || ...
141,179
<p>My Wordpress website is located at example.com/wordpress and I need everything inside to be accessible only using SSL.</p> <p>I've created a .htaccess rule that redirects http -> https:</p> <pre><code>RewriteEngine On RewriteRule ^/?(.*) https://%{SERVER_NAME}/wordpress/directory/$1 [R,L] </code></pre> <p>After i...
[ { "answer_id": 141183, "author": "Frederik Spang", "author_id": 25242, "author_profile": "https://wordpress.stackexchange.com/users/25242", "pm_score": 2, "selected": false, "text": "<p>Without being an htaccess expert, I'd say you're missing a <code>RewriteCond</code> - A condition.</p>...
2014/04/13
[ "https://wordpress.stackexchange.com/questions/141179", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47689/" ]
My Wordpress website is located at example.com/wordpress and I need everything inside to be accessible only using SSL. I've created a .htaccess rule that redirects http -> https: ``` RewriteEngine On RewriteRule ^/?(.*) https://%{SERVER_NAME}/wordpress/directory/$1 [R,L] ``` After implementing this rule the website...
This is a late answer but this works for me: Change the RewriteCond to this ``` RewriteCond %{HTTP:X-Forwarded-Proto} !https ``` Should be like this: ``` RewriteEngine On RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteRule ^(.*)$ https://yourdomain.com/$1 [R,L] ```
141,264
<p>I'm trying to replace all my child page URLs to include a # automatically</p> <p>example: <a href="http://www.website.com/parentfoo/#childfoo" rel="nofollow">http://www.website.com/parentfoo/#childfoo</a></p> <p>I tried using <code>wp_setup_nav_menu_item</code> to run through all the child menu items and add '#' t...
[ { "answer_id": 141270, "author": "Douglas.Sesar", "author_id": 19945, "author_profile": "https://wordpress.stackexchange.com/users/19945", "pm_score": 0, "selected": false, "text": "<p>What you are trying to do seems like a bad idea; the <code>#</code> symbol is used at the end of a URL ...
2014/04/14
[ "https://wordpress.stackexchange.com/questions/141264", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/44945/" ]
I'm trying to replace all my child page URLs to include a # automatically example: <http://www.website.com/parentfoo/#childfoo> I tried using `wp_setup_nav_menu_item` to run through all the child menu items and add '#' to it but now $menu\_item->post\_name brings up the ID so I don't know how to replace the string co...
This ended up doing the trick. ``` function auto_hashtag( $menu_item ) { if ( ! is_admin() && $menu_item->post_parent > 0) { // url $url = $menu_item->url; $menu_item->url = preg_replace('!/([^/]+)/$!', "/#\\1", $url); } return $menu_item; } add_filter( 'wp_setup_nav_menu_item', '...
141,276
<p>I need a safe place where I can store data about projects that I am working on. This data includes text and files (pictures, sound and video).</p> <p>I want to create a private "blog" for this purpouse that is accessible only by myself.</p> <p>The reason behind this is that I can access the data from anywhere, the...
[ { "answer_id": 141270, "author": "Douglas.Sesar", "author_id": 19945, "author_profile": "https://wordpress.stackexchange.com/users/19945", "pm_score": 0, "selected": false, "text": "<p>What you are trying to do seems like a bad idea; the <code>#</code> symbol is used at the end of a URL ...
2014/04/14
[ "https://wordpress.stackexchange.com/questions/141276", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47689/" ]
I need a safe place where I can store data about projects that I am working on. This data includes text and files (pictures, sound and video). I want to create a private "blog" for this purpouse that is accessible only by myself. The reason behind this is that I can access the data from anywhere, the solution is plat...
This ended up doing the trick. ``` function auto_hashtag( $menu_item ) { if ( ! is_admin() && $menu_item->post_parent > 0) { // url $url = $menu_item->url; $menu_item->url = preg_replace('!/([^/]+)/$!', "/#\\1", $url); } return $menu_item; } add_filter( 'wp_setup_nav_menu_item', '...
141,293
<p>I'm attempting to display <strong>posts</strong> from a <strong>'Uncategorized'</strong> category under a custom taxonomy called <strong>'Reviews'</strong> but without much luck.</p> <p>I'm using <code>get_template_part('loop','review')</code> to call <code>loop-review.php</code> which contains my taxonomy loop but...
[ { "answer_id": 141295, "author": "Justin Kopepasah", "author_id": 25027, "author_profile": "https://wordpress.stackexchange.com/users/25027", "pm_score": 0, "selected": false, "text": "<p>At first glance, I see that your query is calling for <code>'post_type' =&gt; 'page'</code> while th...
2014/04/15
[ "https://wordpress.stackexchange.com/questions/141293", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/45682/" ]
I'm attempting to display **posts** from a **'Uncategorized'** category under a custom taxonomy called **'Reviews'** but without much luck. I'm using `get_template_part('loop','review')` to call `loop-review.php` which contains my taxonomy loop but for some reason, nothing will show up. What gives? Here are the conte...
There are no methods `the_content()` or `the_title()` of your query object. These: ``` $review_query->the_content(); $review_query->the_title(); ``` should just be ``` the_content(); the_title(); ``` If you had [debugging enabled](https://codex.wordpress.org/Debugging_in_WordPress) you would see an error informi...
141,301
<p>I have a normal loop in wordpress and in every post i need to check the value of the post before to compare it with the current post.</p> <p>-- POST 1 -- ** DO NOTHING **</p> <p>-- POST 2 -- ** GET VALUE FROM POST 1 **</p> <p>-- POST 3 -- ** GET VALUE FROM POST 2 **</p> <pre><code>&lt;?php if ( have_posts()...
[ { "answer_id": 141325, "author": "Sormano", "author_id": 48607, "author_profile": "https://wordpress.stackexchange.com/users/48607", "pm_score": 1, "selected": false, "text": "<p>You can use the function <code>get_previous_post()</code> to get the previous post object.</p>\n\n<pre><code>...
2014/04/15
[ "https://wordpress.stackexchange.com/questions/141301", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33235/" ]
I have a normal loop in wordpress and in every post i need to check the value of the post before to compare it with the current post. -- POST 1 -- \*\* DO NOTHING \*\* -- POST 2 -- \*\* GET VALUE FROM POST 1 \*\* -- POST 3 -- \*\* GET VALUE FROM POST 2 \*\* ``` <?php if ( have_posts() ) { while ( have_...
``` <?php $previous_post=null; if ( have_posts() ) { while ( have_posts() ) { the_post(); global $post; if($previous_post!=null) { /// Do what ever you want to do with previous post $previous_post. } $description ...
141,344
<p>I'm searching a way to add a custom button to the TinyMCE editor when clicked insert into the visual editor some text.</p> <p>For example: button called "Hi" when clicked insert into the editor <code>"Hello I'm &lt;B&gt;Mark&lt;/b&gt;!"</code></p> <p>Is it possible? And how?</p>
[ { "answer_id": 156016, "author": "Bindiya Patoliya", "author_id": 34932, "author_profile": "https://wordpress.stackexchange.com/users/34932", "pm_score": 0, "selected": false, "text": "<p>Try this :</p>\n\n<p>Add this code to <code>functions.php</code> file.</p>\n\n<pre><code>add_action(...
2014/04/15
[ "https://wordpress.stackexchange.com/questions/141344", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33504/" ]
I'm searching a way to add a custom button to the TinyMCE editor when clicked insert into the visual editor some text. For example: button called "Hi" when clicked insert into the editor `"Hello I'm <B>Mark</b>!"` Is it possible? And how?
If you do want to make a button from scratch try using this code: ``` <script type="text/javascript" src="<your installation path>/tinymce/tinymce.min.js"></script> <script type="text/javascript"> tinymce.init({ selector: "textarea", toolbar: "mybutton", setup: function(editor) { editor.addButton('...
141,355
<p>I have a bunch of <code>_ai_price_int</code> meta values set up as just numbers. This is how the table looks:</p> <pre> meta_id, post_id, meta_key, meta_value 1309, 1111, _ai_price_int, 6550 1310, 1115, _ai_price_int, 7100 1311, 1113, _ai_price_int, 7500 1312, 1103, _ai_price_int, 6000 ...
[ { "answer_id": 141358, "author": "Stephen S.", "author_id": 5019, "author_profile": "https://wordpress.stackexchange.com/users/5019", "pm_score": 1, "selected": false, "text": "<p>I think you may need to change <code>$query-&gt;set('meta_value', '4000');</code> to <code>$query-&gt;set('m...
2014/04/15
[ "https://wordpress.stackexchange.com/questions/141355", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49384/" ]
I have a bunch of `_ai_price_int` meta values set up as just numbers. This is how the table looks: ``` meta_id, post_id, meta_key, meta_value 1309, 1111, _ai_price_int, 6550 1310, 1115, _ai_price_int, 7100 1311, 1113, _ai_price_int, 7500 1312, 1103, _ai_price_int, 6000 etc. ``` I'm usin...
Use a `meta_query` and set `type` to `NUMERIC`- ``` $query->set('meta_query', array( array( 'key' => '_ai_price_int', 'value' => array(0, 4000), 'compare' => 'BETWEEN', 'type' => 'NUMERIC' ) )); $query->set('meta_key', '_ai_price_int'); $query->set('orderby', 'meta_value_num'); ```
141,393
<p>I'm currently using Advanced Custom Fields and I was wondering if anyone know how to filter categories by custom fields? I have a custom field in my categories using the checkboxes field. I want to make a page that will list categories that contain a specific checkbox field that is ticked. For example I have 3 check...
[ { "answer_id": 141642, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 2, "selected": false, "text": "<p>The issue is that there is no taxonomy meta data like there is for posts. ACF taxonomy data is stored serialized i...
2014/04/16
[ "https://wordpress.stackexchange.com/questions/141393", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17971/" ]
I'm currently using Advanced Custom Fields and I was wondering if anyone know how to filter categories by custom fields? I have a custom field in my categories using the checkboxes field. I want to make a page that will list categories that contain a specific checkbox field that is ticked. For example I have 3 checkbox...
Try something like this : ``` $value = get_field('field_name'); ``` Try whole process based on this <http://www.advancedcustomfields.com/resources/how-to/filter-posts-by-custom-fields/> ``` $value = get_field('field_name', $category->cat_ID); ```
141,402
<p>I'd like to remove the genericons-css styles loaded by default into twentyfourteen theme. </p> <pre><code>&lt;link rel='stylesheet' id='genericons-css' href='http://ffwdconsulting.com/wp/wp-content/themes/twentyfourteen/genericons/genericons.css?ver=3.0.2' type='text/css' media='all' /&gt; </code></pre> <p>I foll...
[ { "answer_id": 141411, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 2, "selected": false, "text": "<p>First of all, you're trying to deregister a stylesheet that doesn't exist. Here is how the genericon st...
2014/04/16
[ "https://wordpress.stackexchange.com/questions/141402", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50417/" ]
I'd like to remove the genericons-css styles loaded by default into twentyfourteen theme. ``` <link rel='stylesheet' id='genericons-css' href='http://ffwdconsulting.com/wp/wp-content/themes/twentyfourteen/genericons/genericons.css?ver=3.0.2' type='text/css' media='all' /> ``` I followed [How to remove CSS file in ...
First of all, you're trying to deregister a stylesheet that doesn't exist. Here is how the genericon stylesheet is enqueued in twenty fourteen ``` wp_enqueue_style( 'genericons', get_template_directory_uri() . '/genericons/genericons.css', array(), '3.0.2' ); ``` You are trying to dequeue the stylesheet file name. H...
141,412
<p>I'm creating a child theme based on <a href="https://wordpress.org/themes/twentyfourteen" rel="nofollow">twentyfourteen</a> and wish to change the custom header image dimensions. The custom header page states:</p> <blockquote> <p>Images should be at least 1260 pixels wide. Suggested width is 1260 pixels. Suggeste...
[ { "answer_id": 141415, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 2, "selected": true, "text": "<p>The is a filter to the custom header function in the twenty fourteen theme. You can use that to add your...
2014/04/16
[ "https://wordpress.stackexchange.com/questions/141412", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3083/" ]
I'm creating a child theme based on [twentyfourteen](https://wordpress.org/themes/twentyfourteen) and wish to change the custom header image dimensions. The custom header page states: > > Images should be at least 1260 pixels wide. Suggested width is 1260 pixels. Suggested height is 240 pixels. > > > This appears...
The is a filter to the custom header function in the twenty fourteen theme. You can use that to add your new sizes. Here is what I use to change the default size. ``` function wpse_custom_header_setup() { add_theme_support( 'custom-header', apply_filters( 'wpse_header_args', array( 'width' ...
141,419
<p>Lately I wanted to upgrade my blog with featured images/post thumbnails. I'm using a custom theme build on the roots theme (this is not a roots theme issue, I believe). The image I upload is 1024x768 and shall be cropped to letterbox format 1024x512.</p> <p>This is the code I'm using in the theme-file:</p> <pre><c...
[ { "answer_id": 141548, "author": "Fyn", "author_id": 50481, "author_profile": "https://wordpress.stackexchange.com/users/50481", "pm_score": 1, "selected": false, "text": "<p>Normally, if you want to crop a thumbnail you have to say so using \"true\" as third parameter.</p>\n\n<pre><code...
2014/04/16
[ "https://wordpress.stackexchange.com/questions/141419", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29222/" ]
Lately I wanted to upgrade my blog with featured images/post thumbnails. I'm using a custom theme build on the roots theme (this is not a roots theme issue, I believe). The image I upload is 1024x768 and shall be cropped to letterbox format 1024x512. This is the code I'm using in the theme-file: ``` <?php if ( ha...
Per [the Codex entry for `the_post_thumbnail()`](http://codex.wordpress.org/Function_Reference/the_post_thumbnail#Parameters), passing an array has not worked since WordPress 3.0: > > PLEASE NOTE: The crop does not work in WP 3.0+. All that is needed for WP 3.0+ is the call for the thumbnail to post. Then proceed to ...
141,421
<p>I'm very new to Wordpress. With the help of my friend I installed Wordpress on my server and finally we have our web online. However, I would like to upload some content in media library but I need to organize it in folders. Now we organized it with date-time hierarchy but its not enough. Is it possible having an ac...
[ { "answer_id": 141548, "author": "Fyn", "author_id": 50481, "author_profile": "https://wordpress.stackexchange.com/users/50481", "pm_score": 1, "selected": false, "text": "<p>Normally, if you want to crop a thumbnail you have to say so using \"true\" as third parameter.</p>\n\n<pre><code...
2014/04/16
[ "https://wordpress.stackexchange.com/questions/141421", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50428/" ]
I'm very new to Wordpress. With the help of my friend I installed Wordpress on my server and finally we have our web online. However, I would like to upload some content in media library but I need to organize it in folders. Now we organized it with date-time hierarchy but its not enough. Is it possible having an acces...
Per [the Codex entry for `the_post_thumbnail()`](http://codex.wordpress.org/Function_Reference/the_post_thumbnail#Parameters), passing an array has not worked since WordPress 3.0: > > PLEASE NOTE: The crop does not work in WP 3.0+. All that is needed for WP 3.0+ is the call for the thumbnail to post. Then proceed to ...
141,442
<p>How can I conditionally load HTML for the home page based on whether or not the user is logged in?</p> <p>Currently my theme has an index.php file. In that file I tried to create:</p> <pre><code>&lt;?php if(is_user_logged_in()) { get_header(); ?&gt; &lt;div id="primary" class="content-area"&gt; &lt;div class=...
[ { "answer_id": 141445, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 3, "selected": true, "text": "<p>First check that there isn't a page set as a front page in \"Reading Setting\". If that is set, <code>in...
2014/04/16
[ "https://wordpress.stackexchange.com/questions/141442", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37934/" ]
How can I conditionally load HTML for the home page based on whether or not the user is logged in? Currently my theme has an index.php file. In that file I tried to create: ``` <?php if(is_user_logged_in()) { get_header(); ?> <div id="primary" class="content-area"> <div class="primary-inner"> <div id="co...
First check that there isn't a page set as a front page in "Reading Setting". If that is set, `index.php` is not used as the home page, but the template of the page you set as front page. In that case, you need to find that template and add you conditional is there. ``` <?php if(is_user_logged_in()) { get_header()...
141,454
<p>So I'm working on a plugin for wordpress, and a novice at it as well. I need to use the ID of a wordpress post, or blog article rather, as a unique reference id, or lets say in database terms, a Unique or Primary key.</p> <p>Does the ID ever change on a blog?</p> <h2>Extra background info..:</h2> <p>I'm using this f...
[ { "answer_id": 141455, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 2, "selected": false, "text": "<p>When a post is saved, all the data is saved in the database, and a unique ID is assigned to that specif...
2014/04/16
[ "https://wordpress.stackexchange.com/questions/141454", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50440/" ]
So I'm working on a plugin for wordpress, and a novice at it as well. I need to use the ID of a wordpress post, or blog article rather, as a unique reference id, or lets say in database terms, a Unique or Primary key. Does the ID ever change on a blog? Extra background info..: ------------------------ I'm using this...
No they don't change, but you shouldn't rely on them for external sites. If we're talking about purely in the database on an individual WordPress site, then: * If it's a published/established post/page then yes, the ID will not change other than to delete it * If its a revision, a draft, etc the ID won't change, but ...
141,479
<p>I have a featured post type and a reviews post type. I would like to include reviews of a certain category (I use categories from the posts type) as well. How could query args be crafted?</p> <p>A crude example:</p> <pre><code>get_posts(array('post_type' =&gt; array('featured-posts', array('review-posts', 'feature...
[ { "answer_id": 141455, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 2, "selected": false, "text": "<p>When a post is saved, all the data is saved in the database, and a unique ID is assigned to that specif...
2014/04/16
[ "https://wordpress.stackexchange.com/questions/141479", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50447/" ]
I have a featured post type and a reviews post type. I would like to include reviews of a certain category (I use categories from the posts type) as well. How could query args be crafted? A crude example: ``` get_posts(array('post_type' => array('featured-posts', array('review-posts', 'featured-category')) ``` Need...
No they don't change, but you shouldn't rely on them for external sites. If we're talking about purely in the database on an individual WordPress site, then: * If it's a published/established post/page then yes, the ID will not change other than to delete it * If its a revision, a draft, etc the ID won't change, but ...
141,505
<p>I have a post_type "products" which has both "Category" and "Brand" taxonomies. Each product has exactly 1 Category, and exactly 1 Brand.</p> <p>I would like to display a menu which first lists the Categories as the top-level menu, and then lists the Brands contained in each as a Sub-Menu.</p> <p>Each Sub-Menu sho...
[ { "answer_id": 142031, "author": "gmazzap", "author_id": 35541, "author_profile": "https://wordpress.stackexchange.com/users/35541", "pm_score": 2, "selected": false, "text": "<p>First of all you need a way to get terms form a taxonomy (brand) related to posts associated to another taxon...
2014/04/16
[ "https://wordpress.stackexchange.com/questions/141505", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50461/" ]
I have a post\_type "products" which has both "Category" and "Brand" taxonomies. Each product has exactly 1 Category, and exactly 1 Brand. I would like to display a menu which first lists the Categories as the top-level menu, and then lists the Brands contained in each as a Sub-Menu. Each Sub-Menu should only display...
First of all you need a way to get terms form a taxonomy (brand) related to posts associated to another taxonomy (category). The fastest "core" way to do it is: 1. get a list of all categories 2. for each category get related products 3. loop products and retrieve related brands This workflow require a nested loop, ...
141,507
<p>I want to display a widget outside the sidebar, but I can't get my code to work.</p> <p>The theme name is <code>radius-primary-sidebar</code> and my widget id is <code>text-20</code> (according to the html in the admin page. See image #1).</p> <p>I've tried using <code>the_widget("radius-primary-sidebar", "widget-...
[ { "answer_id": 142031, "author": "gmazzap", "author_id": 35541, "author_profile": "https://wordpress.stackexchange.com/users/35541", "pm_score": 2, "selected": false, "text": "<p>First of all you need a way to get terms form a taxonomy (brand) related to posts associated to another taxon...
2014/04/16
[ "https://wordpress.stackexchange.com/questions/141507", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50462/" ]
I want to display a widget outside the sidebar, but I can't get my code to work. The theme name is `radius-primary-sidebar` and my widget id is `text-20` (according to the html in the admin page. See image #1). I've tried using `the_widget("radius-primary-sidebar", "widget-id=text-20")`, but that didn't return anythi...
First of all you need a way to get terms form a taxonomy (brand) related to posts associated to another taxonomy (category). The fastest "core" way to do it is: 1. get a list of all categories 2. for each category get related products 3. loop products and retrieve related brands This workflow require a nested loop, ...
141,509
<p>I need to upload a very large video. I can not upload it via the built-in uploader since my upload_max_filesize is set to just 2M and I'm unable to override it (I've set the upload size to 50M and post size to 100M in .htaccess and php_info() does reflect my Changes)</p> <p>When I try to use the browser based uploa...
[ { "answer_id": 141510, "author": "Sam", "author_id": 37548, "author_profile": "https://wordpress.stackexchange.com/users/37548", "pm_score": 0, "selected": false, "text": "<p>Give this plugin a go: <a href=\"http://wordpress.org/plugins/add-from-server\" rel=\"nofollow\">http://wordpress...
2014/04/16
[ "https://wordpress.stackexchange.com/questions/141509", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15235/" ]
I need to upload a very large video. I can not upload it via the built-in uploader since my upload\_max\_filesize is set to just 2M and I'm unable to override it (I've set the upload size to 50M and post size to 100M in .htaccess and php\_info() does reflect my Changes) When I try to use the browser based upload tool ...
Yes, the plugin **@Squideyes** [suggests you](https://wordpress.stackexchange.com/a/141510/35541), is perfectly fine, and should do the trick. However, I don't like the link-to-plugin only answers, so here the mine. If you upload the file to a subfolder of the WordPress uploads folder (by default `wp-content/uploads`...
141,513
<p>I have a wordpress table like so (phpmyadmin and MySQL)</p> <pre><code>| id | meta_key | meta_value | +----+-----------+------------+ | 1 | import_id | abc | | 2 | import_id | abc | | 3 | import_id | def | | 4 | import_id | xyz | | 5 | import_id | xyz | | 6 | import_id | xy...
[ { "answer_id": 194532, "author": "Cameron L", "author_id": 76218, "author_profile": "https://wordpress.stackexchange.com/users/76218", "pm_score": 2, "selected": false, "text": "<p>if you want to keep the row with the lowest id value:</p>\n\n<pre><code>DELETE n1 FROM table n1, table n2 W...
2014/04/17
[ "https://wordpress.stackexchange.com/questions/141513", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50393/" ]
I have a wordpress table like so (phpmyadmin and MySQL) ``` | id | meta_key | meta_value | +----+-----------+------------+ | 1 | import_id | abc | | 2 | import_id | abc | | 3 | import_id | def | | 4 | import_id | xyz | | 5 | import_id | xyz | | 6 | import_id | xyz | | 7...
if you want to keep the row with the lowest id value: ``` DELETE n1 FROM table n1, table n2 WHERE n1.id > n2.id AND n1.meta_key = n2.meta_key ``` OR if you want to keep the row with the highest id value: ``` DELETE n1 FROM table n1, table n2 WHERE n1.id < n2.id AND n1.meta_key= n2.meta_key ```
141,523
<p><strong>I have a multiple word press installations that I am trying to reduce to one.</strong></p> <p>Here is what it currently looks like:</p> <pre><code>Installation 1 = www.example.com Installation 2 = www.example.com/foo Installation 3 = www.example.com/foo/bar </code></pre> <p>How do I make it into one insta...
[ { "answer_id": 141633, "author": "Margaret", "author_id": 43394, "author_profile": "https://wordpress.stackexchange.com/users/43394", "pm_score": 0, "selected": false, "text": "<p>If I'm understanding your question correctly, as long as you're okay with them all using the same theme (it ...
2014/04/16
[ "https://wordpress.stackexchange.com/questions/141523", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43988/" ]
**I have a multiple word press installations that I am trying to reduce to one.** Here is what it currently looks like: ``` Installation 1 = www.example.com Installation 2 = www.example.com/foo Installation 3 = www.example.com/foo/bar ``` How do I make it into one installation like this: ``` www.example.com/foo/ba...
You can create sub directories by making parent pages: Say you want it like this: ``` example.com/topicnamebutnocontent/informationontopic ``` *Note: `/topicbutnoname` is a page/direcory that has no content.* --- You can create it this way: * Make a blank page (it does not have to be blank) E.G. `topicnamebutnoc...
141,524
<p>I've been trying to work with <a href="https://codex.wordpress.org/Conditional_Tags" rel="nofollow">Conditional Tags</a> and cannot wrap my head around this problem. PHP novice here.</p> <p>On sub-pages I need to display the parent page title as well as the page title. I have it working with this:</p> <pre><code>&...
[ { "answer_id": 141529, "author": "Krzysiek Dróżdż", "author_id": 34172, "author_profile": "https://wordpress.stackexchange.com/users/34172", "pm_score": 0, "selected": false, "text": "<pre><code>&lt;?php if ( $post-&gt;post_parent ): ?&gt;\n&lt;h1&gt;&lt;?php echo get_the_title($post-&gt...
2014/04/17
[ "https://wordpress.stackexchange.com/questions/141524", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40679/" ]
I've been trying to work with [Conditional Tags](https://codex.wordpress.org/Conditional_Tags) and cannot wrap my head around this problem. PHP novice here. On sub-pages I need to display the parent page title as well as the page title. I have it working with this: ``` <h1><?php echo get_the_title($post->post_parent)...
I found this in the [Conditional Tags codex](http://codex.wordpress.org/Conditional_Tags#A_PAGE_Page), section 2.12: > > "Note: There is no function to check if a page is a sub-page. We can > get around the problem: > > > ``` if ( is_page() && $post->post_parent > 0 ) { echo "This is a child page"; } ``` S...
141,535
<p>This is the error:</p> <blockquote> <p>Call to a member function check_capabilities() on a non-object in /home/content/54/11786754/html/wp-includes/class-wp-customize-control.php on line 161</p> </blockquote> <p>and this is my code in the functions.php </p> <pre><code>function lmao_customizer_register($wp_custo...
[ { "answer_id": 158212, "author": "starryVere", "author_id": 58306, "author_profile": "https://wordpress.stackexchange.com/users/58306", "pm_score": 1, "selected": false, "text": "<p>I'm still relatively new to Wordpress Development, but shouldn't this code be in customizer.php, in the \"...
2014/04/17
[ "https://wordpress.stackexchange.com/questions/141535", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50476/" ]
This is the error: > > Call to a member function check\_capabilities() on a non-object in /home/content/54/11786754/html/wp-includes/class-wp-customize-control.php on line 161 > > > and this is my code in the functions.php ``` function lmao_customizer_register($wp_customize) { $wp_customize->add_section('lmao_...
I'm still relatively new to Wordpress Development, but shouldn't this code be in customizer.php, in the "inc" folder(which would be within your active theme's folder)? Also I know the codex says this particular code is just for the live preview, but after adding it in one of my projects it seemed to fix my issue. So y...
141,551
<p>I developed a small plugin that adds (or to be more precise: first deletes then adds again) some custom user roles. Each of these roles is set up in a way like this:</p> <pre><code>function wpdev_141551_add_role_someone() { $role = 'someone'; remove_role( $role ); $capabilities = array( 'read...
[ { "answer_id": 141705, "author": "tfrommen", "author_id": 27722, "author_profile": "https://wordpress.stackexchange.com/users/27722", "pm_score": 3, "selected": true, "text": "<p>The <a href=\"https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/l10n.php#L695\" rel=\"nofollow...
2014/04/17
[ "https://wordpress.stackexchange.com/questions/141551", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27722/" ]
I developed a small plugin that adds (or to be more precise: first deletes then adds again) some custom user roles. Each of these roles is set up in a way like this: ``` function wpdev_141551_add_role_someone() { $role = 'someone'; remove_role( $role ); $capabilities = array( 'read' => ...
The [`translate_user_role`](https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/l10n.php#L695) function is just a wrapper for [`translate_with_gettext_context`](https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/l10n.php#L107), defining the context 'User role'. In this last function, there i...
141,613
<p>I want to create a form on a page but how do I handle the form submission. </p> <p>Which hook should i implement to handle my submission? Probably dirtiest would be to do it in the theme itself but I don't want it that way... probably not the right way to do it</p>
[ { "answer_id": 141676, "author": "rozklad", "author_id": 47861, "author_profile": "https://wordpress.stackexchange.com/users/47861", "pm_score": 3, "selected": true, "text": "<p>I would use init hook in your plugin file to register custom function</p>\n\n<pre><code>add_action( 'init', 'c...
2014/04/17
[ "https://wordpress.stackexchange.com/questions/141613", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50109/" ]
I want to create a form on a page but how do I handle the form submission. Which hook should i implement to handle my submission? Probably dirtiest would be to do it in the theme itself but I don't want it that way... probably not the right way to do it
I would use init hook in your plugin file to register custom function ``` add_action( 'init', 'custom_proccess_form' ); ``` And then check form inputs in the custom function, you mentioned creating posts ``` function custom_proccess_form() { $wp_error = true; // report errors or not $nonce = $_POST['_wpn...
141,623
<p>I've used this script below inside functions.php since WP 3.5</p> <p>It converts the standard category description editor to a rich text editor. Unfortunately, after upgrading sites to WP 3.9, the description editor is back to a standard text area.</p> <p>Any ideas what I need to change for 3.9?</p> <pre><code>ad...
[ { "answer_id": 141676, "author": "rozklad", "author_id": 47861, "author_profile": "https://wordpress.stackexchange.com/users/47861", "pm_score": 3, "selected": true, "text": "<p>I would use init hook in your plugin file to register custom function</p>\n\n<pre><code>add_action( 'init', 'c...
2014/04/17
[ "https://wordpress.stackexchange.com/questions/141623", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6620/" ]
I've used this script below inside functions.php since WP 3.5 It converts the standard category description editor to a rich text editor. Unfortunately, after upgrading sites to WP 3.9, the description editor is back to a standard text area. Any ideas what I need to change for 3.9? ``` add_action('load-categories.ph...
I would use init hook in your plugin file to register custom function ``` add_action( 'init', 'custom_proccess_form' ); ``` And then check form inputs in the custom function, you mentioned creating posts ``` function custom_proccess_form() { $wp_error = true; // report errors or not $nonce = $_POST['_wpn...
141,627
<p>How do I detect errors when using $wpdb->get_results()?</p> <p>For example:</p> <pre><code>$result = $wpdb-&gt;get_results("SELECT * FROM this is not a valid query"); </code></pre> <p>The preceding code doesn't generate any exceptions or errors; it simply sets $result to an empty array. How do we reliably detect...
[ { "answer_id": 141630, "author": "rinogo", "author_id": 10388, "author_profile": "https://wordpress.stackexchange.com/users/10388", "pm_score": 1, "selected": false, "text": "<p>The best I can find is:</p>\n\n<pre><code>$wpdb-&gt;show_errors();\n$result = $wpdb-&gt;get_results(\"SELECT *...
2014/04/17
[ "https://wordpress.stackexchange.com/questions/141627", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10388/" ]
How do I detect errors when using $wpdb->get\_results()? For example: ``` $result = $wpdb->get_results("SELECT * FROM this is not a valid query"); ``` The preceding code doesn't generate any exceptions or errors; it simply sets $result to an empty array. How do we reliably detect errors generated by get\_results()?
There is a class variable that stores the last error string - $wpdb->last\_error. By the looks of the way $wpdb is coded, if the query succeeds, $wpdb->last\_error will be an empty string, if it fails, it will be the error string returned by MySQL. So something like this would do the trick. ``` $result = $wpdb->get_re...
141,649
<p>What I am trying to do is display every post from the "News" category (in my case the "news" category's ID is 13), with 5 posts per page. The pagination links display on the page, but when I click on the 'previous' link, it will only show me the first 5 posts in the category.</p> <p>The contents of page-news.php:</...
[ { "answer_id": 141650, "author": "HamzStramGram", "author_id": 33749, "author_profile": "https://wordpress.stackexchange.com/users/33749", "pm_score": 0, "selected": false, "text": "<p>Try to get the paged variable set using this :</p>\n\n<pre><code>$paged = (get_query_var('paged')) ? ge...
2014/04/18
[ "https://wordpress.stackexchange.com/questions/141649", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34028/" ]
What I am trying to do is display every post from the "News" category (in my case the "news" category's ID is 13), with 5 posts per page. The pagination links display on the page, but when I click on the 'previous' link, it will only show me the first 5 posts in the category. The contents of page-news.php: ``` <?php ...
You're mixing query string and array parameters. They should either be a single string, like: ``` $wp_query = new WP_Query( 'cat=13&paged=' . $paged ); ``` or an array of key/value parameters, like: ``` $wp_query = new WP_Query( array( 'cat' => 13, 'paged' => $paged ) ); ```
141,670
<p>In theme development, what is the best way to register and enqueue JavaScript files to avoid problems with plugins?</p> <p>I want to create a theme which uses scripts like jQuery, Masonry and so on. I downloaded the scripts and added them via the reqister and enqueue function to <strong>avoid problems with Wordpres...
[ { "answer_id": 141674, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 3, "selected": true, "text": "<p>I would use jquery-masonry included in Wordpress core:</p>\n\n<pre><code>function my_scripts() {\n wp_enque...
2014/04/18
[ "https://wordpress.stackexchange.com/questions/141670", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50528/" ]
In theme development, what is the best way to register and enqueue JavaScript files to avoid problems with plugins? I want to create a theme which uses scripts like jQuery, Masonry and so on. I downloaded the scripts and added them via the reqister and enqueue function to **avoid problems with Wordpress Updates**. ``...
I would use jquery-masonry included in Wordpress core: ``` function my_scripts() { wp_enqueue_script( 'jquery-masonry', true ); } add_action( 'wp_enqueue_scripts', 'my_scripts' ); ``` If you really need the standalone masonry library, you should use your "first way" but I would not use "my\_masonry" as handle fo...
141,708
<p>Since upgrading to Wordpress 3.9 (which includes TinyMCE 4.x), I have problems customizing the editor, displayed via <code>wp_editor()</code></p> <p>In the example below, I want to disable the 'fullscreen' button, but this doesn't work.</p> <pre><code> $settings = array( 'textarea_name' =&gt; 'description', ...
[ { "answer_id": 141728, "author": "Taras Dashkevych", "author_id": 50561, "author_profile": "https://wordpress.stackexchange.com/users/50561", "pm_score": 5, "selected": true, "text": "<p>Try this:</p>\n\n<p>replace</p>\n\n<pre><code>'theme_advanced_disable' =&gt; 'fullscreen'\n</code></p...
2014/04/18
[ "https://wordpress.stackexchange.com/questions/141708", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48847/" ]
Since upgrading to Wordpress 3.9 (which includes TinyMCE 4.x), I have problems customizing the editor, displayed via `wp_editor()` In the example below, I want to disable the 'fullscreen' button, but this doesn't work. ``` $settings = array( 'textarea_name' => 'description', 'quicktags' => false, ...
Try this: replace ``` 'theme_advanced_disable' => 'fullscreen' ``` with ``` 'toolbar1'=> 'bold,italic,underline,bullist,numlist,link,unlink,forecolor,undo,redo' ``` Also, remove `'teeny' => true,`
141,709
<p>I want to change the default screen option value for posts per page in the wp-admin area when listing posts in <code>pending</code> mode. The default value is set to <code>20</code>. </p> <p>Changing the value directly in the Screen Options tab will only affect the user, not all users like <a href="https://stackove...
[ { "answer_id": 141714, "author": "Krzysiek Dróżdż", "author_id": 34172, "author_profile": "https://wordpress.stackexchange.com/users/34172", "pm_score": 2, "selected": false, "text": "<p>It won't be very hard to do. Just add this to your functions.php or into your plugin:</p>\n\n<pre><co...
2014/04/18
[ "https://wordpress.stackexchange.com/questions/141709", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24875/" ]
I want to change the default screen option value for posts per page in the wp-admin area when listing posts in `pending` mode. The default value is set to `20`. Changing the value directly in the Screen Options tab will only affect the user, not all users like [this answer](https://stackoverflow.com/questions/2071872...
Just an addiction to [@KrzysiekDróżdż answer](https://wordpress.stackexchange.com/a/141714/35541). When viewing a specific post status the url query string variable `'post_status'`, is set to the name of the status, so you can use `$_GET['post_status']` to narrow the effect of @KrzysiekDróżdż code only for pending pos...
141,726
<p>I'm coding a plugin which probably will have updates in the future, and I want to take advantage of the automatic update mechanism in wordpress.</p> <p>I followed <a href="http://code.tutsplus.com/tutorials/a-guide-to-the-wordpress-http-api-automatic-plugin-updates--wp-25181" rel="noreferrer">this tutorial</a>:</p>...
[ { "answer_id": 147902, "author": "J.D.", "author_id": 27757, "author_profile": "https://wordpress.stackexchange.com/users/27757", "pm_score": 2, "selected": false, "text": "<p>You actually have several questions in there, so I'll answer them one by one:</p>\n\n<blockquote>\n <p>However,...
2014/04/18
[ "https://wordpress.stackexchange.com/questions/141726", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48700/" ]
I'm coding a plugin which probably will have updates in the future, and I want to take advantage of the automatic update mechanism in wordpress. I followed [this tutorial](http://code.tutsplus.com/tutorials/a-guide-to-the-wordpress-http-api-automatic-plugin-updates--wp-25181): Everything seemed quite straightforward ...
You actually have several questions in there, so I'll answer them one by one: > > However, if I simply do this on my main plugin file, it doesn't work: > > > `add_filter('pre_set_site_transient_update_plugins', array('XYZ', 'check_update'));` > > > First of all, I'd like to understand what's the difference betwe...
141,743
<p>I have being looking in internet how can I disable the option of edit profile in Wordpress for a user and I didn't find a good way. The problem is that I want that the 95% of users can edit their profiles (address, telephone,...) but there is another 5% that I don't want them to have access to the profile section. T...
[ { "answer_id": 141746, "author": "gmazzap", "author_id": 35541, "author_profile": "https://wordpress.stackexchange.com/users/35541", "pm_score": 3, "selected": true, "text": "<p>If you want to completerly remove the possibility for an user to access on profile, you can</p>\n<ol>\n<li>Giv...
2014/04/18
[ "https://wordpress.stackexchange.com/questions/141743", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50567/" ]
I have being looking in internet how can I disable the option of edit profile in Wordpress for a user and I didn't find a good way. The problem is that I want that the 95% of users can edit their profiles (address, telephone,...) but there is another 5% that I don't want them to have access to the profile section. The ...
If you want to completerly remove the possibility for an user to access on profile, you can 1. Give admin possibility to choose which user can access on profile and which not 2. Remove the profile link from menu and from admin bar 3. Ensure the profile is not accessible even if accessed directly by manually typing add...
141,749
<p>I want to make a parallax type link, but I have no idea how to go about it yet. I need to get all post titles with # link and then I can try the parallax thing. </p> <p>My current category page code bellow. I want to show all post in there..</p> <pre><code>&lt;div class="content"&gt; &lt;?php if ( have_posts()...
[ { "answer_id": 141751, "author": "Accore LTD", "author_id": 38766, "author_profile": "https://wordpress.stackexchange.com/users/38766", "pm_score": 1, "selected": true, "text": "<p>i found one way. and is showing properly. .but i am not sure is that perfect way or not. please give your s...
2014/04/19
[ "https://wordpress.stackexchange.com/questions/141749", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38766/" ]
I want to make a parallax type link, but I have no idea how to go about it yet. I need to get all post titles with # link and then I can try the parallax thing. My current category page code bellow. I want to show all post in there.. ``` <div class="content"> <?php if ( have_posts() ) : ?> <h2><?php single_...
i found one way. and is showing properly. .but i am not sure is that perfect way or not. please give your suggestion ``` <ul> <?php $test = get_the_title(); $args = array( 'cat_name' => $test ); $args = array_merge( $args , $wp_query->query ); get_posts( $args ); while (have_posts()) { the_post(); ?> <li data...
141,765
<p>I am a beginner but have spent a lot of time in trying to figure this out and to no avail.</p> <p>Using the developer tool in Chrome I have tried to find a particular class that's unique to the posts that show as previews in the homepage of a new WP site I am creating. But all of them are also applied to the <em>ma...
[ { "answer_id": 141751, "author": "Accore LTD", "author_id": 38766, "author_profile": "https://wordpress.stackexchange.com/users/38766", "pm_score": 1, "selected": true, "text": "<p>i found one way. and is showing properly. .but i am not sure is that perfect way or not. please give your s...
2014/04/19
[ "https://wordpress.stackexchange.com/questions/141765", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50576/" ]
I am a beginner but have spent a lot of time in trying to figure this out and to no avail. Using the developer tool in Chrome I have tried to find a particular class that's unique to the posts that show as previews in the homepage of a new WP site I am creating. But all of them are also applied to the *main post* that...
i found one way. and is showing properly. .but i am not sure is that perfect way or not. please give your suggestion ``` <ul> <?php $test = get_the_title(); $args = array( 'cat_name' => $test ); $args = array_merge( $args , $wp_query->query ); get_posts( $args ); while (have_posts()) { the_post(); ?> <li data...
141,766
<p>In WordPress 3.9 there is a new feature that can make a playlist with uploaded audio files. I'd like to use external audio files. I use two web hosts. One for my website and one for my audio files.</p>
[ { "answer_id": 141782, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 2, "selected": false, "text": "<p>When you construct a playlist and add it to your post content, you get a shortcode like this one:</p>\n\n<pre...
2014/04/19
[ "https://wordpress.stackexchange.com/questions/141766", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14448/" ]
In WordPress 3.9 there is a new feature that can make a playlist with uploaded audio files. I'd like to use external audio files. I use two web hosts. One for my website and one for my audio files.
Playlist shortcode with external audio or video files ----------------------------------------------------- Here I explain how you can implement *idea 3* in my other answer, where we use the following shortcode structure: ``` [wpse_playlist type="" current="" style="" tracklist="" tracknumbers="" images="" artist=""]...
141,767
<p>I'd like to add a download button to the core wp audio player (mediaelement.js).</p> <p>How can I do that simply? Any suggestions?</p>
[ { "answer_id": 142974, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": false, "text": "<h2>How to use a custom playlist template:</h2>\n\n<p>You can overwrite the playlist template with your own temp...
2014/04/19
[ "https://wordpress.stackexchange.com/questions/141767", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14448/" ]
I'd like to add a download button to the core wp audio player (mediaelement.js). How can I do that simply? Any suggestions?
How to use a custom playlist template: -------------------------------------- You can overwrite the playlist template with your own template: ``` /** * Remove the native playlist template and load our custom template * @link http://wordpress.stackexchange.com/q/141767/26350 */ add_action( 'wp_playlist_scripts', '...
141,769
<p>I have a couple of functions that I now combined in a class. The reason for that was that all these functions go towards one goal, and it is more appropriate way to use the globals between these functions. The class consists of three main sections, section one to add my meta boxes, section two adds a options page wh...
[ { "answer_id": 141771, "author": "isNaN", "author_id": 50552, "author_profile": "https://wordpress.stackexchange.com/users/50552", "pm_score": 1, "selected": false, "text": "<p>You can add the is_admin() function in your constructor to separate the logic.</p>\n\n<pre><code>/* php */\npub...
2014/04/19
[ "https://wordpress.stackexchange.com/questions/141769", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31545/" ]
I have a couple of functions that I now combined in a class. The reason for that was that all these functions go towards one goal, and it is more appropriate way to use the globals between these functions. The class consists of three main sections, section one to add my meta boxes, section two adds a options page where...
Your real problem is the god class. You put rendering, sanitation, validation, saving and fetching data, and registration into one class. [Separate your tasks](http://en.wikipedia.org/wiki/Separation_of_concerns) to make it it OOP, and let the main class be a very simple front controller that handles the initial regis...
141,783
<p>I have a project in which i made a custom registration page but the problem is that my password field value not added to the database while email and username properly added. I could not understand why password value not stored. this is my php code.</p> <pre><code> $pwd1 = $wpdb-&gt;escape(trim($_POST['pwd1']))...
[ { "answer_id": 141816, "author": "Sormano", "author_id": 48607, "author_profile": "https://wordpress.stackexchange.com/users/48607", "pm_score": 0, "selected": false, "text": "<p>So far I can see your <code>apply filters</code> are not correct, they shouldn't have a double <code>'pre_use...
2014/04/19
[ "https://wordpress.stackexchange.com/questions/141783", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/44924/" ]
I have a project in which i made a custom registration page but the problem is that my password field value not added to the database while email and username properly added. I could not understand why password value not stored. this is my php code. ``` $pwd1 = $wpdb->escape(trim($_POST['pwd1'])); $pwd2 = $wp...
You don't need to call `'pre_user_*'` filters, that are called by WordPress inside `wp_insert_user`. Also I suggest to use php `filter_input` or `filter_input_array` to sanitize form input. Example code: ``` $args = array( 'pwd1' => FILTER_SANITIZE_STRING, 'pwd2' => FILTER_SANITIZE_STRING, 'first_n...
141,786
<p>I am creating a theme but find the CSS file too long, would it be acceptable to split the CSS file into several so a typograhy.css buttons.css table.css or would that reduce performance and cause other problems? or are there better ways of managing CSS files.</p>
[ { "answer_id": 141816, "author": "Sormano", "author_id": 48607, "author_profile": "https://wordpress.stackexchange.com/users/48607", "pm_score": 0, "selected": false, "text": "<p>So far I can see your <code>apply filters</code> are not correct, they shouldn't have a double <code>'pre_use...
2014/04/19
[ "https://wordpress.stackexchange.com/questions/141786", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/36773/" ]
I am creating a theme but find the CSS file too long, would it be acceptable to split the CSS file into several so a typograhy.css buttons.css table.css or would that reduce performance and cause other problems? or are there better ways of managing CSS files.
You don't need to call `'pre_user_*'` filters, that are called by WordPress inside `wp_insert_user`. Also I suggest to use php `filter_input` or `filter_input_array` to sanitize form input. Example code: ``` $args = array( 'pwd1' => FILTER_SANITIZE_STRING, 'pwd2' => FILTER_SANITIZE_STRING, 'first_n...
141,830
<p>If I am using my own created custom theme, the Post Categories Page in admin panel is not getting updated automatically when I add a new Category. <strong>To see the new category I have to reload the page Manually</strong>.</p> <p>When I change to default themes it works as perfectly. So the problem is in my theme....
[ { "answer_id": 141816, "author": "Sormano", "author_id": 48607, "author_profile": "https://wordpress.stackexchange.com/users/48607", "pm_score": 0, "selected": false, "text": "<p>So far I can see your <code>apply filters</code> are not correct, they shouldn't have a double <code>'pre_use...
2014/04/20
[ "https://wordpress.stackexchange.com/questions/141830", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49748/" ]
If I am using my own created custom theme, the Post Categories Page in admin panel is not getting updated automatically when I add a new Category. **To see the new category I have to reload the page Manually**. When I change to default themes it works as perfectly. So the problem is in my theme. I think I must have m...
You don't need to call `'pre_user_*'` filters, that are called by WordPress inside `wp_insert_user`. Also I suggest to use php `filter_input` or `filter_input_array` to sanitize form input. Example code: ``` $args = array( 'pwd1' => FILTER_SANITIZE_STRING, 'pwd2' => FILTER_SANITIZE_STRING, 'first_n...
141,837
<p>In my WooCommerce theme I've created a root category: 'Brands' then for each product I've added it's brand as a sub category to the 'Brands' parent category.</p> <p>On the product page I want to display the brand of the current product.</p> <pre><code>global $post; // Get the brands ID from slug $brands_id = get_...
[ { "answer_id": 141904, "author": "tommyf", "author_id": 31382, "author_profile": "https://wordpress.stackexchange.com/users/31382", "pm_score": 2, "selected": false, "text": "<p>Don't need <code>get_term_children()</code> at all. Just loop through <code>get_the_terms()</code> to get what...
2014/04/20
[ "https://wordpress.stackexchange.com/questions/141837", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31382/" ]
In my WooCommerce theme I've created a root category: 'Brands' then for each product I've added it's brand as a sub category to the 'Brands' parent category. On the product page I want to display the brand of the current product. ``` global $post; // Get the brands ID from slug $brands_id = get_term_by('slug', 'bran...
Don't need `get_term_children()` at all. Just loop through `get_the_terms()` to get what's needed. ``` global $post; $brands_id = get_term_by('slug', 'brands', 'product_cat'); $terms = get_the_terms($post->ID, 'product_cat'); foreach ($terms as $term) { if($term->parent === $brands_id->term_id) { echo $te...
141,878
<p>I've looked everywhere, but i can't find a solution.</p> <p>My secondary menu isn't adding any current classes to the <li> tags when it's rendered. </p> <p>I have added this menu in my functions.php file</p> <pre><code>function register_menus() { register_nav_menus( array( 'second-menu' =&...
[ { "answer_id": 141879, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": false, "text": "<p>These don't match:</p>\n\n<pre><code>register_nav_menus(\n array(\n 'second-menu' =&gt; __( 'Sec...
2014/04/20
[ "https://wordpress.stackexchange.com/questions/141878", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27645/" ]
I've looked everywhere, but i can't find a solution. My secondary menu isn't adding any current classes to the - tags when it's rendered. I have added this menu in my functions.php file ``` function register_menus() { register_nav_menus( array( 'second-menu' => __( 'Second Menu' ) ) ...
You need to assign the menu to the particular theme option from the admin end, Orelse use this code, ``` wp_nav_menu( array( 'menu' => 'second-menu' ) ); ``` Instead of, ``` wp_nav_menu( array( 'theme_location' => 'second-menu' ) ); ``` This will work.
141,881
<p>I am trying to change an argument in the tax query in the main WP_QUERY object for creating the archive view for my the archive of my hierarchical taxonomy. My goal is to change one of the arguments in the tax query while leaving the rest intact.</p> <p>I tried to get the current query, modify the tax_query array a...
[ { "answer_id": 141889, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 1, "selected": false, "text": "<p>Please try the following:</p>\n\n<pre><code>add_action( 'pre_get_posts', function( $query) {\n if( is_...
2014/04/20
[ "https://wordpress.stackexchange.com/questions/141881", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25300/" ]
I am trying to change an argument in the tax query in the main WP\_QUERY object for creating the archive view for my the archive of my hierarchical taxonomy. My goal is to change one of the arguments in the tax query while leaving the rest intact. I tried to get the current query, modify the tax\_query array and then ...
[**@birgire** answer](https://wordpress.stackexchange.com/a/141889/35541) is fine (+1 from me), however `$query->tax_query->queries` can contain more than one taxonomy, and `$query->tax_query->queries[0]` can be the query for another taxonomy. So, if you want to set `'include_children'` to false (note that it is a boo...
141,883
<p>This is driving me crazy, so please help me guys with this.</p> <p>I'm trying to add a metatag to custom taxonomy ter archive page header which contains the url of the term archive page of a custom taxonomy.</p> <p>How to get the URL of the archive page when there's neither specified term nor the taxonomy itself.<...
[ { "answer_id": 141917, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 2, "selected": false, "text": "<p>If you are in term archive page, the taxonomy and term is actually set. You could hook <code>wp_head</code> t...
2014/04/20
[ "https://wordpress.stackexchange.com/questions/141883", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33233/" ]
This is driving me crazy, so please help me guys with this. I'm trying to add a metatag to custom taxonomy ter archive page header which contains the url of the term archive page of a custom taxonomy. How to get the URL of the archive page when there's neither specified term nor the taxonomy itself.
I finally found the right answer for my question: First add this code: ``` function get_tax_data($data){ if(!$data) return; global $wp_query; $term = $wp_query->get_queried_object(); if($data == 'title') return $term->name; if($data == 'description') return strip_tags($te...
141,896
<p>I'm using <code>get_post_gallery_images</code> and it's spitting images out as 150x150. It doesn't look like it takes a size parameter, so I assumed it would just spit out the largest image or preferably one of my defined sizes. 150x150 is too small though, is there somewhere I can declare what size gallery images I...
[ { "answer_id": 141901, "author": "user2367837", "author_id": 50601, "author_profile": "https://wordpress.stackexchange.com/users/50601", "pm_score": 0, "selected": false, "text": "<p>Check: <a href=\"https://codex.wordpress.org/Function_Reference/add_image_size\" rel=\"nofollow\">https:/...
2014/04/20
[ "https://wordpress.stackexchange.com/questions/141896", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35858/" ]
I'm using `get_post_gallery_images` and it's spitting images out as 150x150. It doesn't look like it takes a size parameter, so I assumed it would just spit out the largest image or preferably one of my defined sizes. 150x150 is too small though, is there somewhere I can declare what size gallery images I want? For in...
If you want `get_post_gallery_images` to give you *full* size images, you can use the following: ``` // Use full size gallery images for the next gallery shortcode: add_filter( 'shortcode_atts_gallery', 'wpse_141896_shortcode_atts_gallery' ); // Your code: $gallery = get_post_gallery_images( $post ); foreach ($galle...
141,897
<p>I have a plugin that adds meta boxes to the admin interface and I need to do some validation when the user presses the "update" button before the form is submitted. </p> <p>Is there a WordPress action or hook to add my function to the form's onsubmit? Or do I need to simply do this:</p> <p><strong>Pseudo code</str...
[ { "answer_id": 141922, "author": "raccol", "author_id": 50367, "author_profile": "https://wordpress.stackexchange.com/users/50367", "pm_score": -1, "selected": false, "text": "<p>This code might help you. I didn't try it in the dashboard but I use it in a page-template.</p>\n\n<pre><code...
2014/04/21
[ "https://wordpress.stackexchange.com/questions/141897", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48989/" ]
I have a plugin that adds meta boxes to the admin interface and I need to do some validation when the user presses the "update" button before the form is submitted. Is there a WordPress action or hook to add my function to the form's onsubmit? Or do I need to simply do this: **Pseudo code** ``` var myInput = docume...
Every post / page / post type is wrapped around a universal form with the ID of `#post`. So if you want to validate a page before submitting it you just need to say something like: ``` jQuery(document).ready(function($){ $('#post').submit(function(){ // Validate Stuff return false; }); }); ```...
141,898
<p>I am trying to make a copy of a live site on a test server. I installed wp-cli and wp-cli sometimes works and sometimes doesn't. When it doesn't work, it just returns nothing. Not one character of output. I can view the website, apache, php and mysql all seem to be working. I turned on <code>WP_DEBUG</code> in <code...
[ { "answer_id": 175929, "author": "DiverseAndRemote.com", "author_id": 23690, "author_profile": "https://wordpress.stackexchange.com/users/23690", "pm_score": 0, "selected": false, "text": "<p>If you only installed php5-cli then you probably don't have php5-mysql. Try running <code>sudo a...
2014/04/21
[ "https://wordpress.stackexchange.com/questions/141898", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50616/" ]
I am trying to make a copy of a live site on a test server. I installed wp-cli and wp-cli sometimes works and sometimes doesn't. When it doesn't work, it just returns nothing. Not one character of output. I can view the website, apache, php and mysql all seem to be working. I turned on `WP_DEBUG` in `wp-config.php` and...
You need to use the --url flag when you have a multisite. ``` wp-cli --debug --url=www.example.com ``` or ``` wp theme list --url=www.example.com ```
141,906
<p>I'm encountering this very frustrating problem where <code>add_image_size()</code> just doesn't seem to work at all (in fact, I've never seen it even work before). By not working, I mean not resizing / crop (if I take away my CSS width / height, the thumbnail will be the exact size in which I have uploaded it).</p> ...
[ { "answer_id": 141908, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 4, "selected": true, "text": "<p>There are a couple of things to check here. </p>\n\n<p>First, make sure that <a href=\"http://codex.word...
2014/04/21
[ "https://wordpress.stackexchange.com/questions/141906", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35704/" ]
I'm encountering this very frustrating problem where `add_image_size()` just doesn't seem to work at all (in fact, I've never seen it even work before). By not working, I mean not resizing / crop (if I take away my CSS width / height, the thumbnail will be the exact size in which I have uploaded it). I do have: 1. `a...
There are a couple of things to check here. First, make sure that [`add_theme_support( 'post-thumbnails' )`](http://codex.wordpress.org/Function_Reference/add_theme_support) is loaded before `add_image_size( 'small-thumb', 60, 60, true )` You can always hook everything through a function to the [`after_setup_theme`]...
141,936
<p>I am writing a WordPress plugin that has a dashboard URL like this...</p> <pre><code>http://www.mydomain.com/wp-admin/admin.php?page=my-plugin.php </code></pre> <p>I have a datepicker box within the page that I use to select a date then click submit like this...</p> <pre><code>&lt;form action="http://www.mydomain...
[ { "answer_id": 141938, "author": "Harish Kanakarajan", "author_id": 50626, "author_profile": "https://wordpress.stackexchange.com/users/50626", "pm_score": 3, "selected": true, "text": "<p>Try to use this code,</p>\n\n<pre><code>&lt;form action=\"http://www.mydomain.com/wp-admin/admin.ph...
2014/04/21
[ "https://wordpress.stackexchange.com/questions/141936", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10247/" ]
I am writing a WordPress plugin that has a dashboard URL like this... ``` http://www.mydomain.com/wp-admin/admin.php?page=my-plugin.php ``` I have a datepicker box within the page that I use to select a date then click submit like this... ``` <form action="http://www.mydomain.com/wp-admin/admin.php?page=my-plugin.p...
Try to use this code, ``` <form action="http://www.mydomain.com/wp-admin/admin.php" method="get"> <input type="hidden" name="page" value="my-plugin.php" /> <input type="text" class="mydatepicker" name="start_date" value=""/> <input type="submit" value="submit"> </form> ``` This will show the url like this... ``` ht...
141,937
<p>I am creating a new post using the <code>wp_insert_post</code> function. Here's what that code looks like:</p> <pre><code>$new_post = array( 'post_title' =&gt; $newtitle, 'post_status' =&gt; 'publish', 'post_content' =&gt; $repost[content], 'post_excerpt' =&gt; $repos...
[ { "answer_id": 141938, "author": "Harish Kanakarajan", "author_id": 50626, "author_profile": "https://wordpress.stackexchange.com/users/50626", "pm_score": 3, "selected": true, "text": "<p>Try to use this code,</p>\n\n<pre><code>&lt;form action=\"http://www.mydomain.com/wp-admin/admin.ph...
2014/04/21
[ "https://wordpress.stackexchange.com/questions/141937", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50634/" ]
I am creating a new post using the `wp_insert_post` function. Here's what that code looks like: ``` $new_post = array( 'post_title' => $newtitle, 'post_status' => 'publish', 'post_content' => $repost[content], 'post_excerpt' => $repost[excerpt], 'post_author'...
Try to use this code, ``` <form action="http://www.mydomain.com/wp-admin/admin.php" method="get"> <input type="hidden" name="page" value="my-plugin.php" /> <input type="text" class="mydatepicker" name="start_date" value=""/> <input type="submit" value="submit"> </form> ``` This will show the url like this... ``` ht...
141,954
<p>I am trying to create the 3 boxes that appear right below navigation and the email sign-up form. Is there a plugin to create something like that? Or what is a possible way to accomplish this sort of thing?</p> <p><img src="https://i.stack.imgur.com/38snZ.jpg" alt="enter image description here"></p> <p>Here is what...
[ { "answer_id": 141938, "author": "Harish Kanakarajan", "author_id": 50626, "author_profile": "https://wordpress.stackexchange.com/users/50626", "pm_score": 3, "selected": true, "text": "<p>Try to use this code,</p>\n\n<pre><code>&lt;form action=\"http://www.mydomain.com/wp-admin/admin.ph...
2014/04/21
[ "https://wordpress.stackexchange.com/questions/141954", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34846/" ]
I am trying to create the 3 boxes that appear right below navigation and the email sign-up form. Is there a plugin to create something like that? Or what is a possible way to accomplish this sort of thing? ![enter image description here](https://i.stack.imgur.com/38snZ.jpg) Here is what I tried to do for posting the ...
Try to use this code, ``` <form action="http://www.mydomain.com/wp-admin/admin.php" method="get"> <input type="hidden" name="page" value="my-plugin.php" /> <input type="text" class="mydatepicker" name="start_date" value=""/> <input type="submit" value="submit"> </form> ``` This will show the url like this... ``` ht...
141,962
<p>I've just uploaded a wordpress site from MAMP to a live site. Exactly the same methods I usually use to upload them, including permalinks and all the usual PHPMyAdmin bits. </p> <p>This time the style.css, js and all the images are just redirecting to a 404 page. </p> <p>The website is <a href="http://www.kenchris...
[ { "answer_id": 141966, "author": "bigant841", "author_id": 50508, "author_profile": "https://wordpress.stackexchange.com/users/50508", "pm_score": 1, "selected": false, "text": "<p>replace </p>\n\n<pre><code> &lt;link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"&lt;?php bl...
2014/04/21
[ "https://wordpress.stackexchange.com/questions/141962", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/36334/" ]
I've just uploaded a wordpress site from MAMP to a live site. Exactly the same methods I usually use to upload them, including permalinks and all the usual PHPMyAdmin bits. This time the style.css, js and all the images are just redirecting to a 404 page. The website is [here](http://www.kenchristy-ruralsupport.com...
Your directory permissions for your Theme directory are incorrect. > > * wp-content: 0755 > * wp-content/themes: 0755 > * wp-content/themes/kenchristy: 0700 > > > [Per the Codex](http://codex.wordpress.org/Changing_File_Permissions#Shared_Hosting_with_suexec), folder permissions should be set to `755`: In such a...
141,967
<p>Working on a theme and I'd like the copyright and title texts on the footer to be automated. It works but the tittle switches to the current page instead of the website's main title when you switch pages. How do I get it to stick to the website's main title or home page title.</p> <p>My line of code is as shown bel...
[ { "answer_id": 141970, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 3, "selected": true, "text": "<p><code>the_title</code> is always the title of the current post. What you probably want is something like <cod...
2014/04/21
[ "https://wordpress.stackexchange.com/questions/141967", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22594/" ]
Working on a theme and I'd like the copyright and title texts on the footer to be automated. It works but the tittle switches to the current page instead of the website's main title when you switch pages. How do I get it to stick to the website's main title or home page title. My line of code is as shown below. ``` ...
`the_title` is always the title of the current post. What you probably want is something like `wp_title` or `get_bloginfo` and `bloginfo('name');`. Take a look at your headers code to see exactly what your theme uses
141,971
<p>From what I can see, <code>dbDelta()</code> is designed to suppress database errors that occur during its operation. Generally speaking, this seems to be the case, but New Relic is still reporting MysqlErrors from the function. The exact error message is of the format:</p> <pre><code>MysqlError: Table 'xxx.wp_yyy...
[ { "answer_id": 141984, "author": "Lance Cleveland", "author_id": 11553, "author_profile": "https://wordpress.stackexchange.com/users/11553", "pm_score": 0, "selected": false, "text": "<p>DB errors of that type should only appear on the UI if DB_DEBUG is enabled. On a production system t...
2014/04/21
[ "https://wordpress.stackexchange.com/questions/141971", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10388/" ]
From what I can see, `dbDelta()` is designed to suppress database errors that occur during its operation. Generally speaking, this seems to be the case, but New Relic is still reporting MysqlErrors from the function. The exact error message is of the format: ``` MysqlError: Table 'xxx.wp_yyy_posts' doesn't exist ``` ...
As @Charleston Software Associates mentioned, the DESCRIBE query should not be executed if the table doesn't exist. The best solution, as he pointed out, is to prevent the error from occurring in the first place. To do so, patch `wp-admin/includes/upgrade.php` as follows: Change the following line from dbDelta(): ``...
141,985
<p>I am getting</p> <pre><code>Fatal error: Call to undefined function add_filter() in example.com/wp-config.php on line 20 </code></pre> <p>after adding </p> <pre><code>add_filter( 'auto_update_plugin', '__return_true' ); </code></pre> <p>to wp-config.php</p> <p>My plugins.php file is present and add_filter() is ...
[ { "answer_id": 141987, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 3, "selected": true, "text": "<p>There is a section that should look like this:</p>\n\n<pre><code>defined( 'ABSPATH' ) || define( 'ABSPATH', __DIR__ . ...
2014/04/21
[ "https://wordpress.stackexchange.com/questions/141985", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47689/" ]
I am getting ``` Fatal error: Call to undefined function add_filter() in example.com/wp-config.php on line 20 ``` after adding ``` add_filter( 'auto_update_plugin', '__return_true' ); ``` to wp-config.php My plugins.php file is present and add\_filter() is defined inside of it. I just want to enable automatic ...
There is a section that should look like this: ``` defined( 'ABSPATH' ) || define( 'ABSPATH', __DIR__ . '/' ); require_once( ABSPATH . 'wp-settings.php' ); ``` `add_filter()` is available **after** that, you are probably using it too early.
141,986
<p>I have a self-hosted Wordpress blog on my home server. Previously I accessed it directly via its original IP address taken from DHCP, but now I have configured a static IP address for it. The problem is that now all the CSS is broken.</p> <p>I have updated my <code>wp-config.php</code> file adding the following two...
[ { "answer_id": 142053, "author": "David Gard", "author_id": 10097, "author_profile": "https://wordpress.stackexchange.com/users/10097", "pm_score": 0, "selected": false, "text": "<p>The WordPress Codex '<a href=\"http://codex.wordpress.org/Changing_The_Site_URL\" rel=\"nofollow\">Changin...
2014/04/21
[ "https://wordpress.stackexchange.com/questions/141986", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/44459/" ]
I have a self-hosted Wordpress blog on my home server. Previously I accessed it directly via its original IP address taken from DHCP, but now I have configured a static IP address for it. The problem is that now all the CSS is broken. I have updated my `wp-config.php` file adding the following two lines: ``` define('...
For some reason, changing the URL from the GUI worked (after restoring the machine to the old IP address). Go figure.
142,004
<p>This question came up when creating a custom meta box for the edit.php page.</p> <p>Is there a conditional statement to target posts that are already exist vs posts that are not created yet?</p> <p>The idea:</p> <pre><code>If editing post (post exists) { // Display custom input field } else if adding post (post ...
[ { "answer_id": 142007, "author": "Krzysiek Dróżdż", "author_id": 34172, "author_profile": "https://wordpress.stackexchange.com/users/34172", "pm_score": 1, "selected": false, "text": "<p>Something like this should work:</p>\n\n<pre><code>global $current_screen;\n\nif ( $current_screen-&g...
2014/04/22
[ "https://wordpress.stackexchange.com/questions/142004", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28389/" ]
This question came up when creating a custom meta box for the edit.php page. Is there a conditional statement to target posts that are already exist vs posts that are not created yet? The idea: ``` If editing post (post exists) { // Display custom input field } else if adding post (post does not exist) // Hide cus...
`edit.php` is the post/page **list**, the post creation/editing screen are 2 separate files: `post-new.php` and `post.php`. so you can target using [`"load-$page"`](https://codex.wordpress.org/Plugin_API/Action_Reference/load-%28page%29) hook, e.g.: ``` add_action( 'load-post.php', function() { // add metabox or wh...
142,026
<p>I'm writing a plugin. I want to run the method get_my_option when someone pressing a button in the settings page of my wordpress plugin. The ajax call is made but the method never runs.</p> <p>In the page I have the following code:</p> <pre><code>&lt;div class="wrap"&gt; &lt;input type="button" value="test" onclic...
[ { "answer_id": 142052, "author": "Dave Ross", "author_id": 3851, "author_profile": "https://wordpress.stackexchange.com/users/3851", "pm_score": 4, "selected": true, "text": "<p>Where are you calling add_action()? If it's in a place where you're already outputting HTML, it's too late, an...
2014/04/22
[ "https://wordpress.stackexchange.com/questions/142026", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50661/" ]
I'm writing a plugin. I want to run the method get\_my\_option when someone pressing a button in the settings page of my wordpress plugin. The ajax call is made but the method never runs. In the page I have the following code: ``` <div class="wrap"> <input type="button" value="test" onclick="my_js_function();"/> </di...
Where are you calling add\_action()? If it's in a place where you're already outputting HTML, it's too late, and that's probably a place that wont even be looked at during an AJAX request. You should include that code in your theme's functions.php file, or as early as possible in a plugin.