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
106,961
<p>I can't seem to get pagination to work correctly in my search results template. The page links appear, but when i click onto page 2, it gives me a 404 error.</p> <p><strong>Search.php</strong></p> <pre><code>&lt;?php global $wp_query; $total_results = $wp_query-&gt;found_posts; ?&gt; &lt;?php if(!$wp_query) globa...
[ { "answer_id": 106941, "author": "Vitaliy Kukin", "author_id": 34421, "author_profile": "https://wordpress.stackexchange.com/users/34421", "pm_score": -1, "selected": false, "text": "<p>use <a href=\"http://api.jquery.com/ready/\" rel=\"nofollow\">$.ready</a> <code>jQuery(document).ready...
2013/07/18
[ "https://wordpress.stackexchange.com/questions/106961", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34375/" ]
I can't seem to get pagination to work correctly in my search results template. The page links appear, but when i click onto page 2, it gives me a 404 error. **Search.php** ``` <?php global $wp_query; $total_results = $wp_query->found_posts; ?> <?php if(!$wp_query) global $wp_query; $search_refer = $_GET["post_type"...
did you try the image editor class hooks? try: image\_editor\_save\_pre more information about the hooks changes: <http://make.wordpress.org/core/2012/12/06/wp_image_editor-is-incoming/> <http://codex.wordpress.org/Class_Reference/WP_Image_Editor>
106,962
<p>I'm not even sure this is possible but before I start thinking up crazy solutions, I'll see if there is a WordPress way to do it.</p> <p>Here's the deal.</p> <p>I have a timeline jQuery plugin all set up on WordPress and I want it to be callable in a child theme through the add_theme_support method:</p> <pre><cod...
[ { "answer_id": 254210, "author": "Vivek Tamrakar", "author_id": 96956, "author_profile": "https://wordpress.stackexchange.com/users/96956", "pm_score": -1, "selected": false, "text": "<pre><code>add_theme_support( 'timeline' );\n</code></pre>\n\n<p>Add this code in your functions.php fil...
2013/07/18
[ "https://wordpress.stackexchange.com/questions/106962", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28719/" ]
I'm not even sure this is possible but before I start thinking up crazy solutions, I'll see if there is a WordPress way to do it. Here's the deal. I have a timeline jQuery plugin all set up on WordPress and I want it to be callable in a child theme through the add\_theme\_support method: ``` add_theme_support( 'time...
OK, so it all comes to finding proper filter to modify the list of available templates... The list of templates comes from [`get_page_templates`](https://codex.wordpress.org/Function_Reference/get_page_templates) function, but there are no filters in it's code. But... It uses method `get_page_templates` of class `WP_T...
106,973
<p>Need to insert custom post type objects from code. Haven't been able to add using the default method</p> <pre><code>$id = wp_insert_post(array('post_title'=&gt;'random', 'post_type'=&gt;'custom_post')); </code></pre> <p>creates a regular post instead.</p>
[ { "answer_id": 106984, "author": "Ravinder Kumar", "author_id": 29439, "author_profile": "https://wordpress.stackexchange.com/users/29439", "pm_score": 5, "selected": true, "text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/wp_insert_post#Example\" rel=\"nofollow norefer...
2013/07/18
[ "https://wordpress.stackexchange.com/questions/106973", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13626/" ]
Need to insert custom post type objects from code. Haven't been able to add using the default method ``` $id = wp_insert_post(array('post_title'=>'random', 'post_type'=>'custom_post')); ``` creates a regular post instead.
[From the Codex](http://codex.wordpress.org/Function_Reference/wp_insert_post#Example): > > [wp\_insert\_post()](http://codex.wordpress.org/Function_Reference/wp_insert_post#Example) will fill out a default list of these but the > user is required to provide the title and content otherwise the > database write will...
106,983
<p>I have included the following into my wp-config.php file:</p> <pre><code>define( 'FORCE_SSL_LOGIN', true ); define( 'FORCE_SSL_ADMIN', true); </code></pre> <p>But getting these error messages at the login screen for my WP dashboard:</p> <p>Notice: Constant FORCE_SSL_LOGIN already defined in D:\xampp\htdocs\wordpr...
[ { "answer_id": 106987, "author": "Johannes Pille", "author_id": 9745, "author_profile": "https://wordpress.stackexchange.com/users/9745", "pm_score": 0, "selected": false, "text": "<p>You cannot redefine a <a href=\"http://www.php.net/manual/en/language.constants.php\" rel=\"nofollow\">c...
2013/07/18
[ "https://wordpress.stackexchange.com/questions/106983", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34825/" ]
I have included the following into my wp-config.php file: ``` define( 'FORCE_SSL_LOGIN', true ); define( 'FORCE_SSL_ADMIN', true); ``` But getting these error messages at the login screen for my WP dashboard: Notice: Constant FORCE\_SSL\_LOGIN already defined in D:\xampp\htdocs\wordpress01\wp-config.php on line 102...
See [WordPress Administration over SSL page](http://codex.wordpress.org/Administration_Over_SSL). In there, it says : > > The constant FORCE\_SSL\_LOGIN can be set to true to force all logins to > happen over SSL. This (and all other such definitions) must be placed > before > > > `/* That's all, stop editing! Ha...
106,998
<p>How can i integrate a image if there is no attached image?</p> <p>I'm using this code with success to integrate no-image picture if is no picture is attached to post.</p> <pre><code>&lt;?php if ( ! $img = get_field('img_actor', $post_object-&gt;ID ) ) $img = '/wp-content/uploads/noimage1.jpg'; ?&gt; &lt;img cl...
[ { "answer_id": 106987, "author": "Johannes Pille", "author_id": 9745, "author_profile": "https://wordpress.stackexchange.com/users/9745", "pm_score": 0, "selected": false, "text": "<p>You cannot redefine a <a href=\"http://www.php.net/manual/en/language.constants.php\" rel=\"nofollow\">c...
2013/07/18
[ "https://wordpress.stackexchange.com/questions/106998", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17885/" ]
How can i integrate a image if there is no attached image? I'm using this code with success to integrate no-image picture if is no picture is attached to post. ``` <?php if ( ! $img = get_field('img_actor', $post_object->ID ) ) $img = '/wp-content/uploads/noimage1.jpg'; ?> <img class="actor_img" src="/scripts/tim...
See [WordPress Administration over SSL page](http://codex.wordpress.org/Administration_Over_SSL). In there, it says : > > The constant FORCE\_SSL\_LOGIN can be set to true to force all logins to > happen over SSL. This (and all other such definitions) must be placed > before > > > `/* That's all, stop editing! Ha...
107,002
<p>Ok, I have a few CPT's setup with a metabox that only requires some values for some categories. When searching a specific category, I want to display a link to the value (which is a url) if it exists and not show it if it doesn't. What I have right now show's all three buttons whether the value exists or not. Any...
[ { "answer_id": 107005, "author": "Vigs", "author_id": 33573, "author_profile": "https://wordpress.stackexchange.com/users/33573", "pm_score": -1, "selected": true, "text": "<pre><code>&lt;?php if(strlen(get_post_meta($post-&gt;ID, 'recent_action', true)) !== 0){ ?&gt;\n &lt;a ...
2013/07/18
[ "https://wordpress.stackexchange.com/questions/107002", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35190/" ]
Ok, I have a few CPT's setup with a metabox that only requires some values for some categories. When searching a specific category, I want to display a link to the value (which is a url) if it exists and not show it if it doesn't. What I have right now show's all three buttons whether the value exists or not. Anyone kn...
``` <?php if(strlen(get_post_meta($post->ID, 'recent_action', true)) !== 0){ ?> <a class="button" href="<?php echo get_post_meta($post->ID, "recent_action", true); ?>">Recent Action Link</a> <?php } elseif(strlen(get_post_meta($post->ID, 'related_link', true)) !== 0){ ?> <a class="button" href="...
107,009
<p>I'm looking into using <a href="http://tgmpluginactivation.com/" rel="nofollow">http://tgmpluginactivation.com/</a> to activate required plugins for my custom theme during the theme activation step.</p> <p>From what I can tell, this class only Activates plugins automatically, but it doesn't automatically Install pl...
[ { "answer_id": 107968, "author": "Mike", "author_id": 30824, "author_profile": "https://wordpress.stackexchange.com/users/30824", "pm_score": 1, "selected": false, "text": "<p>The <code>activate_plugin</code> function should be what you're looking for. Place it in a <code>after_setup_the...
2013/07/18
[ "https://wordpress.stackexchange.com/questions/107009", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34754/" ]
I'm looking into using <http://tgmpluginactivation.com/> to activate required plugins for my custom theme during the theme activation step. From what I can tell, this class only Activates plugins automatically, but it doesn't automatically Install plugins I have bundled with my theme. Does anyone know if it's possibl...
Edited Answer: TMG is a very popular auto plugin installer for WordPress and a lot of Premium theme author use it. You can get the php class here <https://github.com/thomasgriffin/TGM-Plugin-Activation>. Also when you will download it you will get a php file named example.php. You just have to include that example.php...
107,044
<p>Hello I am getting a Error of the Wordpress includes, this error appears when I post the multiple values of a taxonomy</p> <pre><code>&lt;form role="search" method="post" id="searchform" action="&lt;?php echo home_url( '/' ); ?&gt;"&gt; &lt;select name="books[]" multiple&gt; &lt;option value="a"&gt;a&lt;/option&...
[ { "answer_id": 107309, "author": "user1073323", "author_id": 35491, "author_profile": "https://wordpress.stackexchange.com/users/35491", "pm_score": -1, "selected": true, "text": "<p>solved with; <strong>query_var => false</strong></p>\n\n<pre><code>register_taxonomy('taxname', 'post_typ...
2013/07/18
[ "https://wordpress.stackexchange.com/questions/107044", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35491/" ]
Hello I am getting a Error of the Wordpress includes, this error appears when I post the multiple values of a taxonomy ``` <form role="search" method="post" id="searchform" action="<?php echo home_url( '/' ); ?>"> <select name="books[]" multiple> <option value="a">a</option> <option value="b">b</option> </select>...
solved with; **query\_var => false** ``` register_taxonomy('taxname', 'post_type', array('hierarchical' => true, 'label' => 'lable', 'query_var' => false, 'rewrite' => array('slug' => 'slug'))); ```
107,047
<p>Do any of you know of a way to center the main menu on my company's site? I have been trying all day and am frazzled! I've tried editing the stylesheet but nothing has fixed it. I've tried throwing <code>white-space: nowrap</code> around in the CSS but it had no effect regardless of where I put it. Ahh!</p> <p>We'r...
[ { "answer_id": 107051, "author": "Dejo Dekic", "author_id": 20941, "author_profile": "https://wordpress.stackexchange.com/users/20941", "pm_score": 2, "selected": false, "text": "<p>Try this :</p>\n\n<pre><code>#catnav, #catnav ul {\ndisplay: block;\nfont-size: 8px;\nline-height: 1;\nlis...
2013/07/18
[ "https://wordpress.stackexchange.com/questions/107047", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35494/" ]
Do any of you know of a way to center the main menu on my company's site? I have been trying all day and am frazzled! I've tried editing the stylesheet but nothing has fixed it. I've tried throwing `white-space: nowrap` around in the CSS but it had no effect regardless of where I put it. Ahh! We're using the Meta-Morp...
Try this : ``` #catnav, #catnav ul { display: block; font-size: 8px; line-height: 1; list-style: none outside none; margin: 0 auto; padding: 0; position: relative; width: 594px; z-index: 999; } ```
107,062
<p>I have several <strong>unpublished</strong> posts in my Wordpress website and I am trying to make it accessible for normal users (who are not logged in) using the normal post slugs (<code>site.com/post-here</code>). I understand it may not be the best practice but for my special purpose, this needs to be done.</p> ...
[ { "answer_id": 107084, "author": "Georgi Demirev", "author_id": 25900, "author_profile": "https://wordpress.stackexchange.com/users/25900", "pm_score": 0, "selected": false, "text": "<p>I think the \"User Role Editor\" plugin available at WordPress.org's website might be what you're look...
2013/07/18
[ "https://wordpress.stackexchange.com/questions/107062", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35498/" ]
I have several **unpublished** posts in my Wordpress website and I am trying to make it accessible for normal users (who are not logged in) using the normal post slugs (`site.com/post-here`). I understand it may not be the best practice but for my special purpose, this needs to be done. I have tried adding the followi...
You cannot assign capabilities to unknown users. If you want to make a post visible for everyone, create a separate URL for these posts and add a control element to the post editor to enable the preview on selected posts only. When such an URL is called, check if a preview is allowed for the post and if the post has...
107,070
<p>I can't figure out how to remove the word "date from the permalink for yearly archives. For example: </p> <p>[http://localhost/wordpress/news/date/2012]</p> <p>On single news pages the permalink looks like this:</p> <p>[http://localhost/wordpress/news/2012/news-article/]</p> <p>I've created a custom post type ca...
[ { "answer_id": 107084, "author": "Georgi Demirev", "author_id": 25900, "author_profile": "https://wordpress.stackexchange.com/users/25900", "pm_score": 0, "selected": false, "text": "<p>I think the \"User Role Editor\" plugin available at WordPress.org's website might be what you're look...
2013/07/18
[ "https://wordpress.stackexchange.com/questions/107070", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10272/" ]
I can't figure out how to remove the word "date from the permalink for yearly archives. For example: [http://localhost/wordpress/news/date/2012] On single news pages the permalink looks like this: [http://localhost/wordpress/news/2012/news-article/] I've created a custom post type called "News". The slug for this ...
You cannot assign capabilities to unknown users. If you want to make a post visible for everyone, create a separate URL for these posts and add a control element to the post editor to enable the preview on selected posts only. When such an URL is called, check if a preview is allowed for the post and if the post has...
107,095
<p>I am struggling to create custom rewrite rules for wordpress.</p> <p>This is my url structure</p> <pre><code>http://domain/cityprofile/?city=Sydney </code></pre> <p>where city profile is a page template.</p> <p>Now i want to make this url as </p> <pre><code>http://domain/Sydney </code></pre> <p>.htaccess </p...
[ { "answer_id": 112215, "author": "tfrommen", "author_id": 27722, "author_profile": "https://wordpress.stackexchange.com/users/27722", "pm_score": 0, "selected": false, "text": "<p>First of all, you do know that this will collide with pages (and when having permalink set to <code>%postnam...
2013/07/19
[ "https://wordpress.stackexchange.com/questions/107095", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17807/" ]
I am struggling to create custom rewrite rules for wordpress. This is my url structure ``` http://domain/cityprofile/?city=Sydney ``` where city profile is a page template. Now i want to make this url as ``` http://domain/Sydney ``` .htaccess ``` # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On ...
~~**[answer updated as wanted]**~~ It's better to hook your function to `generate_rewrite_rules` so you won't have fall into infinite loops and flushing rewrite rule on every request. So you can do this: ``` function add_my_rules($wp_rewrite) { $new_rules = array( '^cityprofile/\?city=(Sydeny|Melbourne|B...
107,096
<p>As I understand it, it's possible to overwrite core functions in wordpress, without touching the core itself, which is of obvious benefit. </p> <p>Now, certain functions are 'pluggable', but not all of them.</p> <p>I'm trying to overwrite the function that outputs the featured image thumbnail in the admin panel to...
[ { "answer_id": 107097, "author": "Pat J", "author_id": 16121, "author_profile": "https://wordpress.stackexchange.com/users/16121", "pm_score": 2, "selected": false, "text": "<p>Only <a href=\"http://codex.wordpress.org/Pluggable_Functions\" rel=\"nofollow\">the functions defined as \"plu...
2013/07/19
[ "https://wordpress.stackexchange.com/questions/107096", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22450/" ]
As I understand it, it's possible to overwrite core functions in wordpress, without touching the core itself, which is of obvious benefit. Now, certain functions are 'pluggable', but not all of them. I'm trying to overwrite the function that outputs the featured image thumbnail in the admin panel to be a custom size...
Only [the functions defined as "pluggable" functions](http://codex.wordpress.org/Pluggable_Functions) can be overridden in a plugin/theme. But... You shouldn't need to rewrite a core function to resize your featured images. See instead [`set_post_thumbnail_size()`](http://codex.wordpress.org/Function_Reference/set_pos...
107,100
<p>I have the following query to extract posts from two different types. However, how can I then target them in the actual content display conditional code?</p> <p>The if ($my_query->post_type == 'featured' ) does not work. I also tried if (post_type == 'featured' ). </p> <pre><code> &lt;?php // query posts $my...
[ { "answer_id": 107097, "author": "Pat J", "author_id": 16121, "author_profile": "https://wordpress.stackexchange.com/users/16121", "pm_score": 2, "selected": false, "text": "<p>Only <a href=\"http://codex.wordpress.org/Pluggable_Functions\" rel=\"nofollow\">the functions defined as \"plu...
2013/07/19
[ "https://wordpress.stackexchange.com/questions/107100", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12651/" ]
I have the following query to extract posts from two different types. However, how can I then target them in the actual content display conditional code? The if ($my\_query->post\_type == 'featured' ) does not work. I also tried if (post\_type == 'featured' ). ``` <?php // query posts $my_query = new WP_Query ...
Only [the functions defined as "pluggable" functions](http://codex.wordpress.org/Pluggable_Functions) can be overridden in a plugin/theme. But... You shouldn't need to rewrite a core function to resize your featured images. See instead [`set_post_thumbnail_size()`](http://codex.wordpress.org/Function_Reference/set_pos...
107,113
<p>I'd like to hook into the loop, ie. have_posts() maybe? and output some code before and after. Is there a filter for this so I can use it in a plugin without needing to edit themes?</p>
[ { "answer_id": 107122, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 4, "selected": true, "text": "<p>The function <code>the_post()</code> (<a href=\"https://github.com/WordPress/WordPress/blob/3.5.2/wp-incl...
2013/07/19
[ "https://wordpress.stackexchange.com/questions/107113", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17467/" ]
I'd like to hook into the loop, ie. have\_posts() maybe? and output some code before and after. Is there a filter for this so I can use it in a plugin without needing to edit themes?
The function `the_post()` ([source](https://github.com/WordPress/WordPress/blob/3.5.2/wp-includes/query.php#L2835)) triggers the action `loop_start` when it is first used in the loop. This is used in *every* `WP_Query` loop, so you may want to check if the current query is the 'main' one (assuming that's the query you ...
107,133
<p>Sorry if this is an ignorant question. I'm a first timer on working with rtl languages. Say we have a theme with standard style.css for English languages. so I use is_rtl() and this returns TRUE, we won't load the style.css and only rtl.css?</p> <p>IF someone can provide an example on this on loading rtl.css on rtl...
[ { "answer_id": 107134, "author": "Lilumi", "author_id": 10969, "author_profile": "https://wordpress.stackexchange.com/users/10969", "pm_score": -1, "selected": false, "text": "<pre><code>if ( is_rtl() ) {\n &lt;link rel=\"stylesheet\" type=\"text/css\" href=\"&lt;? bloginfo('template_di...
2013/07/19
[ "https://wordpress.stackexchange.com/questions/107133", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20972/" ]
Sorry if this is an ignorant question. I'm a first timer on working with rtl languages. Say we have a theme with standard style.css for English languages. so I use is\_rtl() and this returns TRUE, we won't load the style.css and only rtl.css? IF someone can provide an example on this on loading rtl.css on rtl language...
In your theme, you enqueue the stylesheet usually like this: ``` add_action( 'wp_enqueue_scripts', 't5_enqueue_style' ); function t5_enqueue_style() { wp_enqueue_style( 'theme-name-default', get_template_directory_uri() . '/css/default.min.css' ); } ``` The extra RTL stylesheet is enqueued...
107,141
<p>I'm new to WordPress. I am looking for a way to check if current page is the blog page in the code of the header file.</p> <p>I've checked but I can't find a way. Help me, Pls.</p>
[ { "answer_id": 107142, "author": "Xav", "author_id": 22448, "author_profile": "https://wordpress.stackexchange.com/users/22448", "pm_score": 0, "selected": false, "text": "<p>You can use.. </p>\n\n<pre><code>&lt;?php if ( is_single() ) { ?&gt;\n\nDo stuff here\n\n&lt;?php } ?&gt;\n</code...
2013/07/19
[ "https://wordpress.stackexchange.com/questions/107141", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28533/" ]
I'm new to WordPress. I am looking for a way to check if current page is the blog page in the code of the header file. I've checked but I can't find a way. Help me, Pls.
If by '**blog page**' you meant a *static page* set as *posts page* in the **Reading Settings**, then you could check it by doing this: ``` if ( is_front_page() && is_home() ) { // Default homepage } elseif ( is_front_page() ) { // static homepage } elseif ( is_home() ) { // blog page } else { //everyting else...
107,144
<p>I am using wooCommerce. When i set the featured image for a woocommerce product, it shows up as the first/main image in the gallery on the product details page. I need to remove the featured image from the gallery only. How to do this?</p>
[ { "answer_id": 107142, "author": "Xav", "author_id": 22448, "author_profile": "https://wordpress.stackexchange.com/users/22448", "pm_score": 0, "selected": false, "text": "<p>You can use.. </p>\n\n<pre><code>&lt;?php if ( is_single() ) { ?&gt;\n\nDo stuff here\n\n&lt;?php } ?&gt;\n</code...
2013/07/19
[ "https://wordpress.stackexchange.com/questions/107144", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32027/" ]
I am using wooCommerce. When i set the featured image for a woocommerce product, it shows up as the first/main image in the gallery on the product details page. I need to remove the featured image from the gallery only. How to do this?
If by '**blog page**' you meant a *static page* set as *posts page* in the **Reading Settings**, then you could check it by doing this: ``` if ( is_front_page() && is_home() ) { // Default homepage } elseif ( is_front_page() ) { // static homepage } elseif ( is_home() ) { // blog page } else { //everyting else...
107,149
<p>I would like to add a video (autoplay) before the visitor go into my wp blog (maybe just the homepage, not every post), how could this be possible? I think javascript maybe the best choose? </p> <p>Could you give your solution (no matter js or not) in detail?</p> <hr> <p>EDIT:</p> <p>After a while, I think this ...
[ { "answer_id": 107152, "author": "Vigs", "author_id": 33573, "author_profile": "https://wordpress.stackexchange.com/users/33573", "pm_score": 0, "selected": false, "text": "<pre><code>function ron_redirect_to_vid() {\nif(get_transient('ron_first_visit_'.$user-&gt;ID) === false){\nset_tra...
2013/07/19
[ "https://wordpress.stackexchange.com/questions/107149", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34727/" ]
I would like to add a video (autoplay) before the visitor go into my wp blog (maybe just the homepage, not every post), how could this be possible? I think javascript maybe the best choose? Could you give your solution (no matter js or not) in detail? --- EDIT: After a while, I think this should work for me, but t...
**My suggestion :** 1. Make a specific video splash template inside of your WordPress theme incorporating a link to visit the rest of your site. 2. Put in your web directory a specific CSS file for full screen video support. 3. Make a new empty page using the splash template and use this page as your homepage in your ...
107,154
<p>I've been struggling to find the best solution for a better (custom) search. I'm using WordPress for a large Media Catalog, so my intention is to provide better search options.</p> <p>So far I've been able to put various search forms in the archive.php that perform search by: subcategory, tag, custom field(autor) a...
[ { "answer_id": 107152, "author": "Vigs", "author_id": 33573, "author_profile": "https://wordpress.stackexchange.com/users/33573", "pm_score": 0, "selected": false, "text": "<pre><code>function ron_redirect_to_vid() {\nif(get_transient('ron_first_visit_'.$user-&gt;ID) === false){\nset_tra...
2013/07/19
[ "https://wordpress.stackexchange.com/questions/107154", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35530/" ]
I've been struggling to find the best solution for a better (custom) search. I'm using WordPress for a large Media Catalog, so my intention is to provide better search options. So far I've been able to put various search forms in the archive.php that perform search by: subcategory, tag, custom field(autor) and year, a...
**My suggestion :** 1. Make a specific video splash template inside of your WordPress theme incorporating a link to visit the rest of your site. 2. Put in your web directory a specific CSS file for full screen video support. 3. Make a new empty page using the splash template and use this page as your homepage in your ...
107,158
<p>Here is example:</p> <pre><code>$args=array( 'meta_key' =&gt; 'Something', 'meta_value' =&gt; '',//here goes current used ID by default. 'meta_compare' =&gt; '=', ); $user_query = new WP_User_Query( $args ); // User Loop if ( ! empty( $user_query-&gt;results ) ) { foreach ( $user_query-...
[ { "answer_id": 107162, "author": "Vigs", "author_id": 33573, "author_profile": "https://wordpress.stackexchange.com/users/33573", "pm_score": 0, "selected": false, "text": "<p>If the user is logged in when the meta array is saved you can use the <code>$current_user</code> global variable...
2013/07/19
[ "https://wordpress.stackexchange.com/questions/107158", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35534/" ]
Here is example: ``` $args=array( 'meta_key' => 'Something', 'meta_value' => '',//here goes current used ID by default. 'meta_compare' => '=', ); $user_query = new WP_User_Query( $args ); // User Loop if ( ! empty( $user_query->results ) ) { foreach ( $user_query->results as $user ) { ...
`WP_User_Query` is a user search. This sentence... > > But I need to echo only those users name whose meta\_key= something but > meta \_value is equal to current user ID. > > > ... suggests that that is not really what you want. I think you can accomplish this with: ``` $current_user = wp_get_current_user(); $m...
107,195
<p>This is the set up:</p> <pre><code>&lt;form method="post" action=""&gt; &lt;input type="hidden" name="delete_app_id" id="delete_app_id" value='&lt;?php echo $adoptee-&gt;app_id; ?&gt;' /&gt; &lt;input type="submit" name="delete" value="delete" /&gt; &lt;/form&gt; &lt;?php if ( isset( $_POST['delet...
[ { "answer_id": 107201, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 1, "selected": false, "text": "<p>I see no reason why <code>$_POST['delete']</code> should not be set assuming there are no page redirects inv...
2013/07/19
[ "https://wordpress.stackexchange.com/questions/107195", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34049/" ]
This is the set up: ``` <form method="post" action=""> <input type="hidden" name="delete_app_id" id="delete_app_id" value='<?php echo $adoptee->app_id; ?>' /> <input type="submit" name="delete" value="delete" /> </form> <?php if ( isset( $_POST['delete'] ) ) { $delete_id=$_POST['delete_app_id']; ...
I see no reason why `$_POST['delete']` should not be set assuming there are no page redirects involved. I can't tell from your code if that is the case, but it superficially appears not to be. I do see other potential problems. 1. You are setting your form `action` to an empty string. While that does sometimes work, i...
107,198
<p>Ive been fooling around with both Jquery and PHP and Im trying to setup a website for a sports team. I've created a custom post type called "Matches" and in there I've created two Custom Meta Boxes. One for the match details (IE home and away team) and one for match stats (goals, shots etc.). What I currently have...
[ { "answer_id": 107474, "author": "Charles Clarkson", "author_id": 31788, "author_profile": "https://wordpress.stackexchange.com/users/31788", "pm_score": 0, "selected": false, "text": "<p>I simplified your code by removing the WordPress stuff and removing some of your markup. I found it ...
2013/07/19
[ "https://wordpress.stackexchange.com/questions/107198", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19258/" ]
Ive been fooling around with both Jquery and PHP and Im trying to setup a website for a sports team. I've created a custom post type called "Matches" and in there I've created two Custom Meta Boxes. One for the match details (IE home and away team) and one for match stats (goals, shots etc.). What I currently have is a...
Found a solution to it though, pretty simple ``` <script type="text/javascript"> jQuery(document).ready(function($) { var dw_match_display = $('#dw_match_display'); dw_match_display.hide(); if ($('#dw_complete').prop('checked') ) { dw_match_display.show(); } $( '#dw_match_details' ).on( '...
107,218
<p>I have this function call that displays an entire img tag with the correct url for that post.. the thumbnail img...</p> <pre><code>?php the_post_thumbnail('blog-page'); ?&gt; </code></pre> <p>What I need is just the source address for that img. </p> <p>How can I get that source dynamically?</p> <hr> <p>Here is ...
[ { "answer_id": 107474, "author": "Charles Clarkson", "author_id": 31788, "author_profile": "https://wordpress.stackexchange.com/users/31788", "pm_score": 0, "selected": false, "text": "<p>I simplified your code by removing the WordPress stuff and removing some of your markup. I found it ...
2013/07/19
[ "https://wordpress.stackexchange.com/questions/107218", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35549/" ]
I have this function call that displays an entire img tag with the correct url for that post.. the thumbnail img... ``` ?php the_post_thumbnail('blog-page'); ?> ``` What I need is just the source address for that img. How can I get that source dynamically? --- Here is a little more explanation of what it is exac...
Found a solution to it though, pretty simple ``` <script type="text/javascript"> jQuery(document).ready(function($) { var dw_match_display = $('#dw_match_display'); dw_match_display.hide(); if ($('#dw_complete').prop('checked') ) { dw_match_display.show(); } $( '#dw_match_details' ).on( '...
107,222
<p>i'm new in wordpress, and i really need a help here. My main site, list the resume (excrept) of all posts, with pagination. But when a user publish a new post, the only way to see it on the main page is to reload it... I want to know if there's a way to automatic show new posts , like facebook....</p> <p>I didn't f...
[ { "answer_id": 134277, "author": "les", "author_id": 47483, "author_profile": "https://wordpress.stackexchange.com/users/47483", "pm_score": 1, "selected": false, "text": "<p>Your answer definitely falls within the realm of AJAX. If you are using a form, try setting the <code>onsubmit ev...
2013/07/20
[ "https://wordpress.stackexchange.com/questions/107222", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35508/" ]
i'm new in wordpress, and i really need a help here. My main site, list the resume (excrept) of all posts, with pagination. But when a user publish a new post, the only way to see it on the main page is to reload it... I want to know if there's a way to automatic show new posts , like facebook.... I didn't found a way...
Your answer definitely falls within the realm of AJAX. If you are using a form, try setting the `onsubmit eventListener` equal to `return false;` (plus any other needed attributes) like so: ``` <form onsubmit="return false;"> ``` Then you send a post and parse it with PHP and depending on your desired effect, and th...
107,249
<p>I use the built-in tag cloud widget and it's outputting the terms with a title attribute on hover that says "x Topics". How can I remove this title attribute, or better yet, change it to something more meaningful for the current terms.</p> <p>I have already tried this code, but it does not appear to be working:</p>...
[ { "answer_id": 107226, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 3, "selected": true, "text": "<p>You can install CI as a theme or a directory in a theme. Then load the files in the theme’s <code>functions.php</code>...
2013/07/20
[ "https://wordpress.stackexchange.com/questions/107249", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27396/" ]
I use the built-in tag cloud widget and it's outputting the terms with a title attribute on hover that says "x Topics". How can I remove this title attribute, or better yet, change it to something more meaningful for the current terms. I have already tried this code, but it does not appear to be working: ``` // remov...
You can install CI as a theme or a directory in a theme. Then load the files in the theme’s `functions.php` and create the output with CI. You can use all the WordPress code here. As far as I’m aware there will be no conflicts between [CodeIgniter’s reserved names](http://ellislab.com/codeigniter/user-guide/general/re...
107,297
<p>Some HTML elements accept valueless attributes such as <code>&lt;input disabled /&gt;</code> or <code>&lt;video autoplay /&gt;</code></p> <p>How do I handle this case with shortcodes where I want to disable autoplay by default (= omit the attribute at all) but enable it optionally.</p> <p>Possible scenarios:</p> ...
[ { "answer_id": 107299, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": false, "text": "<p>Use <code>0</code> and <code>1</code> as shortcode values and use that show or hide the HTML attribute.</p>\n\n<p>Exa...
2013/07/21
[ "https://wordpress.stackexchange.com/questions/107297", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18760/" ]
Some HTML elements accept valueless attributes such as `<input disabled />` or `<video autoplay />` How do I handle this case with shortcodes where I want to disable autoplay by default (= omit the attribute at all) but enable it optionally. Possible scenarios: ``` // [video] <video> // [video autoplay] <video auto...
Use `0` and `1` as shortcode values and use that show or hide the HTML attribute. Example with an element `input` and the attribute `required`: ``` function input_shortcode( $atts ) { $values = shortcode_atts( array ( 'type' => 'text', 'value' => '', 'name' =...
107,303
<p>i have this custom post_type: tvr_apartment</p> <pre><code>function custom_post_apartment() { $labels = array( 'name' =&gt; 'Apartments', 'singular_name' =&gt; 'Apartment', 'add_new' =&gt; 'Add New', 'add_new_item' =&gt;...
[ { "answer_id": 107326, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 4, "selected": true, "text": "<p>According to extensive and long running trac ticket <a href=\"http://core.trac.wordpress.org/ticket/12702\" rel=\"no...
2013/07/21
[ "https://wordpress.stackexchange.com/questions/107303", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3435/" ]
i have this custom post\_type: tvr\_apartment ``` function custom_post_apartment() { $labels = array( 'name' => 'Apartments', 'singular_name' => 'Apartment', 'add_new' => 'Add New', 'add_new_item' => 'Add New Apartment', ...
According to extensive and long running trac ticket [#12702](http://core.trac.wordpress.org/ticket/12702), custom post types don't (and likely won't) support sticky functionality. It's probably not impossible to reuse it (with unholy amount of copy paste and edge cases) for CPT in custom site, but in my opinion custom...
107,340
<p>I have several loops each of them built to display a certain category in different style, based on user's input (they're within shortcodes). Now I want to "merge" these (or just 1 of them) loops with the loop to display recent posts, regardless of the category.</p> <p>Currently this is my code (to display post from...
[ { "answer_id": 107326, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 4, "selected": true, "text": "<p>According to extensive and long running trac ticket <a href=\"http://core.trac.wordpress.org/ticket/12702\" rel=\"no...
2013/07/21
[ "https://wordpress.stackexchange.com/questions/107340", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18447/" ]
I have several loops each of them built to display a certain category in different style, based on user's input (they're within shortcodes). Now I want to "merge" these (or just 1 of them) loops with the loop to display recent posts, regardless of the category. Currently this is my code (to display post from a certain...
According to extensive and long running trac ticket [#12702](http://core.trac.wordpress.org/ticket/12702), custom post types don't (and likely won't) support sticky functionality. It's probably not impossible to reuse it (with unholy amount of copy paste and edge cases) for CPT in custom site, but in my opinion custom...
107,346
<p>I am writing a custom theme/plugin in which I need to download images programatically from certain webpages to the upload folder and then insert them as part of the post.</p> <p>So, I was able to find the image url's programatically, and then I need to save them to the upload folder under wp-content, however that f...
[ { "answer_id": 107348, "author": "gmazzap", "author_id": 35541, "author_profile": "https://wordpress.stackexchange.com/users/35541", "pm_score": 1, "selected": false, "text": "<p>You have no posted the code used to fetch and save the image, so is impossible to say where is the error.</p>...
2013/07/21
[ "https://wordpress.stackexchange.com/questions/107346", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34253/" ]
I am writing a custom theme/plugin in which I need to download images programatically from certain webpages to the upload folder and then insert them as part of the post. So, I was able to find the image url's programatically, and then I need to save them to the upload folder under wp-content, however that folder has ...
I recently had to do this via a nightly cron script for a social media stream. $parent\_id is the ID of the post you want to attach the image to. ``` function uploadRemoteImageAndAttach($image_url, $parent_id){ $image = $image_url; $get = wp_remote_get( $image ); $type = wp_remote_retrieve_header( $get,...
107,357
<p>I have a sub-domain network installation on <code>www.example.com</code></p> <p>One of the sites is <code>rabbit.example.com</code></p> <p>This site used to have a domain mapping to <code>www.rabbit.com</code>. </p> <p>I removed this mapping.</p> <p>However, when I go to <code>http://rabbit.example.com/wp-admin...
[ { "answer_id": 107348, "author": "gmazzap", "author_id": 35541, "author_profile": "https://wordpress.stackexchange.com/users/35541", "pm_score": 1, "selected": false, "text": "<p>You have no posted the code used to fetch and save the image, so is impossible to say where is the error.</p>...
2013/07/22
[ "https://wordpress.stackexchange.com/questions/107357", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3206/" ]
I have a sub-domain network installation on `www.example.com` One of the sites is `rabbit.example.com` This site used to have a domain mapping to `www.rabbit.com`. I removed this mapping. However, when I go to `http://rabbit.example.com/wp-admin`, it forwards me to `http://www.rabbit.com/wp-admin` I have checked ...
I recently had to do this via a nightly cron script for a social media stream. $parent\_id is the ID of the post you want to attach the image to. ``` function uploadRemoteImageAndAttach($image_url, $parent_id){ $image = $image_url; $get = wp_remote_get( $image ); $type = wp_remote_retrieve_header( $get,...
107,358
<p><a href="http://steven.doig.com.au/">This webpage</a> contains images inserted by Wordpress. The code used to insert the first image is:</p> <pre><code>[caption id="attachment_887" align="alignnone" width="604"] &lt;a href="http://steven.doig.com.au/files/2013/06/Forest_Legacy_m.jpg"&gt; &lt;img class=...
[ { "answer_id": 107361, "author": "David Kryzaniak", "author_id": 31548, "author_profile": "https://wordpress.stackexchange.com/users/31548", "pm_score": 5, "selected": true, "text": "<p>You're going to want to use:</p>\n\n<pre><code>@media (max-width: 988px){\n .wp-caption {\n /* For...
2013/07/22
[ "https://wordpress.stackexchange.com/questions/107358", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3206/" ]
[This webpage](http://steven.doig.com.au/) contains images inserted by Wordpress. The code used to insert the first image is: ``` [caption id="attachment_887" align="alignnone" width="604"] <a href="http://steven.doig.com.au/files/2013/06/Forest_Legacy_m.jpg"> <img class="size-large wp-image-887" alt="a Fo...
You're going to want to use: ``` @media (max-width: 988px){ .wp-caption { /* Force the box to be 100% */ width: 100% !important; } #content .wp-caption a img { /* Scale down if too big */ max-width: 99.03225806%; /* 614/620 */ height: auto; } } ```
107,410
<p>I have CSS issues with a certain div only on the front page (front-page.php). As I can't fix it, I was thinking about removing the item, but only on the front-page.</p> <p>I'm not exactly sure how I have to code this in Wordpress.</p> <p>I want this div in the Header to show up everywhere but on the front-page.php...
[ { "answer_id": 107370, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 3, "selected": true, "text": "<p>No, there is no function for that. You would need a complete JavaScript parser. This is not part of the WordPress core...
2013/07/22
[ "https://wordpress.stackexchange.com/questions/107410", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6903/" ]
I have CSS issues with a certain div only on the front page (front-page.php). As I can't fix it, I was thinking about removing the item, but only on the front-page. I'm not exactly sure how I have to code this in Wordpress. I want this div in the Header to show up everywhere but on the front-page.php: ``` <!-- BEGIN...
No, there is no function for that. You would need a complete JavaScript parser. This is not part of the WordPress core.
107,416
<p>I am using folowing code to store posts ids into array:</p> <pre><code>&lt;?php $args = array( 'post_type' =&gt; 'product', 'post_status' =&gt; 'publish', 'ignore_sticky_posts' =&gt; 1, 'posts_per_page' =&gt; 5, 'orderby' =&gt; 'date', 'order' =&gt; 'desc'); $id...
[ { "answer_id": 107418, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": true, "text": "<p>Try to replace </p>\n\n<pre><code>$id[$counter] = get_the_id();\n</code></pre>\n\n<p>with </p>\n\n<pre><code>a...
2013/07/22
[ "https://wordpress.stackexchange.com/questions/107416", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35318/" ]
I am using folowing code to store posts ids into array: ``` <?php $args = array( 'post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => 5, 'orderby' => 'date', 'order' => 'desc'); $id = array(); $counter = 1; $p...
Try to replace ``` $id[$counter] = get_the_id(); ``` with ``` array_push( $id, get_the_ID() ); ``` to collect the post id's into the `$id` array. Update: ------- If you also use `$ids` instead of `$id`: ``` $args = array( 'post_type' => 'product', 'post_status' => 'publish', 'igno...
107,440
<p>Im trying to further customise my Gravity Forms "Address" labels. At the moment they read "Street Address", "City" and "ZIP / Postal Code".</p> <p>I, for example, want to change "ZIP / Postal Code" to "Post code". Does anyone know if you can use templates to override these values in your theme without messing up th...
[ { "answer_id": 107453, "author": "Pat J", "author_id": 16121, "author_profile": "https://wordpress.stackexchange.com/users/16121", "pm_score": 1, "selected": false, "text": "<p>You sure can. Gravity Forms has <a href=\"http://www.gravityhelp.com/documentation/page/Developer_Docs#Hooks_a...
2013/07/22
[ "https://wordpress.stackexchange.com/questions/107440", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14355/" ]
Im trying to further customise my Gravity Forms "Address" labels. At the moment they read "Street Address", "City" and "ZIP / Postal Code". I, for example, want to change "ZIP / Postal Code" to "Post code". Does anyone know if you can use templates to override these values in your theme without messing up the core GF ...
You can change a bunch in one hit with the [gform\_address\_types](http://www.gravityhelp.com/documentation/page/Gform_address_types) filter, like this: ``` /** * customise the Address field labels * @param array $addressTypes * @return array */ add_filter('gform_address_types', function ($addressTypes) { $address...
107,459
<p>I'm trying to have a page where a user can view all of the custom post types after they click on an author from a previous page, but I'm having no luck with anything I can find in the built-in PHP functions with Wordpress.</p> <p>Is this some easy to query? I haven't found much online about it.</p>
[ { "answer_id": 107460, "author": "Pat J", "author_id": 16121, "author_profile": "https://wordpress.stackexchange.com/users/16121", "pm_score": 3, "selected": false, "text": "<p>Something like this should work:</p>\n<pre><code>// Assuming you've got $author_id set\n// and your post type i...
2013/07/22
[ "https://wordpress.stackexchange.com/questions/107459", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33105/" ]
I'm trying to have a page where a user can view all of the custom post types after they click on an author from a previous page, but I'm having no luck with anything I can find in the built-in PHP functions with Wordpress. Is this some easy to query? I haven't found much online about it.
Something like this should work: ``` // Assuming you've got $author_id set // and your post type is called 'your_post_type' $args = array( 'author' => $author_id, 'post_type' => 'your_post_type', ); $author_posts = new WP_Query( $args ); if( $author_posts->have_posts() ) { while( $author_posts->have_posts(...
107,461
<p>I have a problem to upload images to the media library when is used multi-file uploader on WP 3.5.2. Single file media uploader works fine.</p> <p>I have tested it with 1k PNG image, which was stuck on "crunching" anyway. Debug log for that part came with those messages:</p> <pre><code>[23-Jul-2013 13:41:28] PHP N...
[ { "answer_id": 107465, "author": "Sam", "author_id": 35635, "author_profile": "https://wordpress.stackexchange.com/users/35635", "pm_score": 1, "selected": false, "text": "<p>Try updating file permissions of your WP-content and uploads folder, in most cases this should fix media upload r...
2013/07/22
[ "https://wordpress.stackexchange.com/questions/107461", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28491/" ]
I have a problem to upload images to the media library when is used multi-file uploader on WP 3.5.2. Single file media uploader works fine. I have tested it with 1k PNG image, which was stuck on "crunching" anyway. Debug log for that part came with those messages: ``` [23-Jul-2013 13:41:28] PHP Notice: has_cap was c...
Ok so i'm on wordpress 3.8.1 and i was having this issue and i tried EVERY FIX from every post i could find on this problem of the image upload staying stuck on "crunching" or having it say "image data does not exist" So apparently if the image dimensions (e.g. 1920x1080) are bigger than what you have set for your "ma...
107,469
<p>I'm using the following code to do a tax_query and it doesn't seem to work anymore..</p> <p>At some point it was working and for the life of me it wont, anymore.</p> <pre><code>&lt;?php global $pf_override; class PF_override { public $site_terms = array(); function __construct() { // add filte...
[ { "answer_id": 107473, "author": "Playforward", "author_id": 21170, "author_profile": "https://wordpress.stackexchange.com/users/21170", "pm_score": 4, "selected": true, "text": "<p>Well it seems after digging in to the code, tax_query is being blocked on single post/page pages which is ...
2013/07/23
[ "https://wordpress.stackexchange.com/questions/107469", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21170/" ]
I'm using the following code to do a tax\_query and it doesn't seem to work anymore.. At some point it was working and for the life of me it wont, anymore. ``` <?php global $pf_override; class PF_override { public $site_terms = array(); function __construct() { // add filters add_filter( ...
Well it seems after digging in to the code, tax\_query is being blocked on single post/page pages which is why I'm running in to this issue. **If you see the ability to run tax\_query in all circumstances as beneficial, please voice your opinion on trac.** See ticket here: <http://core.trac.wordpress.org/ticket/24819...
107,493
<p>I've been trying to display posts that I've categorized as "news-categories". My goal is to only display 4 posts on sidebar of "cbs-news" slug underneath "news-categories" category. By below mention code all the post underneath "cbs-news" are displaying. But i need to display only 4 latest post. </p> <pre><code> &l...
[ { "answer_id": 107494, "author": "JMau", "author_id": 31376, "author_profile": "https://wordpress.stackexchange.com/users/31376", "pm_score": 0, "selected": false, "text": "<p>Your query is not correct, try this instead :</p>\n\n<pre><code> $paged = ( get_query_var('paged') ? get_query_v...
2013/07/23
[ "https://wordpress.stackexchange.com/questions/107493", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35123/" ]
I've been trying to display posts that I've categorized as "news-categories". My goal is to only display 4 posts on sidebar of "cbs-news" slug underneath "news-categories" category. By below mention code all the post underneath "cbs-news" are displaying. But i need to display only 4 latest post. ``` <ul class="list4...
You write the wrong code ``` $paged = get_query_var('paged') ? get_query_var('paged') : 1; $args = array('posts_per_page' => '5', 'paged' => $paged, 'tax_query' => array( array('taxonomy' => 'news-categories', 'field' => 'slug', ...
107,498
<p>How can I insert custom message after post title. For example </p> <pre><h2>The Post Title</h2> My custom message</p> </pre>
[ { "answer_id": 107504, "author": "M-R", "author_id": 17061, "author_profile": "https://wordpress.stackexchange.com/users/17061", "pm_score": 3, "selected": true, "text": "<p>You need to use '<a href=\"http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content\" rel=\"nofollow\">t...
2013/07/23
[ "https://wordpress.stackexchange.com/questions/107498", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35653/" ]
How can I insert custom message after post title. For example ``` The Post Title -------------- My custom message ```
You need to use '[the\_content](http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content)' filter ``` function add_before_content($content) { return 'Before content area '.$content; } add_filter('the_content', add_before_content); ``` It will still be inside the content div. If you want it outside the div...
107,509
<p>I'm having trouble getting my custom post type to correctly register. It seems to be identifying as a page post type and using that template. I also can't access the archive page for it. Any idea on what's wrong?</p> <pre><code>add_action( 'init', 'register_cpt_women' ); function register_cpt_women() { $women...
[ { "answer_id": 107510, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 2, "selected": true, "text": "<p>Go to Settings>Permalinks and re-save your permalinks. When you initialize a post type you need to refres...
2013/07/23
[ "https://wordpress.stackexchange.com/questions/107509", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25283/" ]
I'm having trouble getting my custom post type to correctly register. It seems to be identifying as a page post type and using that template. I also can't access the archive page for it. Any idea on what's wrong? ``` add_action( 'init', 'register_cpt_women' ); function register_cpt_women() { $womenLabels = array...
Go to Settings>Permalinks and re-save your permalinks. When you initialize a post type you need to refresh your rewrite rules.
107,513
<p>I am working on the CSS of my wordpress site. When I make changes and refresh the page the changes are not reflected. When I clear the browser history and cache the changes are still reflected. When I view the source code of the page and look at the css file it has the old content before the change. How do I get thi...
[ { "answer_id": 107536, "author": "Jeff Purcell", "author_id": 20339, "author_profile": "https://wordpress.stackexchange.com/users/20339", "pm_score": 0, "selected": false, "text": "<p>It is possible that your host is using something like Varnish to cache your site's output. I ran into th...
2013/07/23
[ "https://wordpress.stackexchange.com/questions/107513", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33563/" ]
I am working on the CSS of my wordpress site. When I make changes and refresh the page the changes are not reflected. When I clear the browser history and cache the changes are still reflected. When I view the source code of the page and look at the css file it has the old content before the change. How do I get this t...
Add a random version number at the end of the css file you are attaching. If you are using '[wp\_enqueue\_style](http://codex.wordpress.org/Function_Reference/wp_enqueue_style)' or [wp\_register\_style](http://codex.wordpress.org/Function_Reference/wp_register_style) functions, pass a random (version) number `rand(111,...
107,519
<p>I am using WAMP with the latest version of WordPress installed. I have a custom post type created using the following...</p> <pre><code>function register_fruit() { register_post_type('fruit', array( 'labels' =&gt; array( 'name' =&gt; __( 'Fruit' ), ), 'public' =&gt; true, 'has_archive' =&gt; true, 'capability_type...
[ { "answer_id": 107520, "author": "GhostToast", "author_id": 13676, "author_profile": "https://wordpress.stackexchange.com/users/13676", "pm_score": 4, "selected": false, "text": "<p>Have you tried refreshing permalinks?\nSettings -> Permalinks (don't have to change anything)\nThen try ag...
2013/07/23
[ "https://wordpress.stackexchange.com/questions/107519", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10247/" ]
I am using WAMP with the latest version of WordPress installed. I have a custom post type created using the following... ``` function register_fruit() { register_post_type('fruit', array( 'labels' => array( 'name' => __( 'Fruit' ), ), 'public' => true, 'has_archive' => true, 'capability_type' => 'post', 'rewrite' => a...
Have you tried refreshing permalinks? Settings -> Permalinks (don't have to change anything) Then try again?
107,528
<p>I'm trying to add a new external/non-WP rewrite rule to my <code>.htaccess</code> but WP keeps adding <code>[QSA,L]</code> to the end of the rule. How do I prevent the QSA part?</p> <p>This line adds the RewriteRule:</p> <pre><code>$wp_rewrite-&gt;add_external_rule('go/([0-9]+)/?.*$', 'wp-content/plugins/xswpc/red...
[ { "answer_id": 149901, "author": "Jonathan Lafleur", "author_id": 10501, "author_profile": "https://wordpress.stackexchange.com/users/10501", "pm_score": 0, "selected": false, "text": "<p>Maybe you can try with <a href=\"http://codex.wordpress.org/Rewrite_API/add_rewrite_rule\" rel=\"nof...
2013/07/23
[ "https://wordpress.stackexchange.com/questions/107528", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35667/" ]
I'm trying to add a new external/non-WP rewrite rule to my `.htaccess` but WP keeps adding `[QSA,L]` to the end of the rule. How do I prevent the QSA part? This line adds the RewriteRule: ``` $wp_rewrite->add_external_rule('go/([0-9]+)/?.*$', 'wp-content/plugins/xswpc/redirect.php?id=$1'); ``` And this is the resul...
The apache rewrite flags like [`QSA`](http://httpd.apache.org/docs/2.2/rewrite/flags.html#flag_qsa) are hard coded, see [source](https://core.trac.wordpress.org/browser/tags/3.9.1/src/wp-includes/rewrite.php#L1802). Not sure why it would bother you, but if you really want to change it, then you can and should use the [...
107,532
<p>How can I hide a div (which contains an image) for a specific WordPress page?</p> <p>I believe my page id is 46:</p> <p><img src="https://i.stack.imgur.com/Ess6T.png" alt="enter image description here"></p> <p>Here is the div I am trying to change:</p> <pre><code>&lt;div id="static-footer-image" style="position:...
[ { "answer_id": 107538, "author": "M-R", "author_id": 17061, "author_profile": "https://wordpress.stackexchange.com/users/17061", "pm_score": 4, "selected": false, "text": "<p>Use following CSS</p>\n\n<pre><code>body.page-id-46 #static-footer-image { \n display: none; \n}\n</code></pr...
2013/07/23
[ "https://wordpress.stackexchange.com/questions/107532", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33563/" ]
How can I hide a div (which contains an image) for a specific WordPress page? I believe my page id is 46: ![enter image description here](https://i.stack.imgur.com/Ess6T.png) Here is the div I am trying to change: ``` <div id="static-footer-image" style="position:absolute; bottom: -15px; z-index: 501;"> <img sr...
Guess from the URL structure, your `%postname%` permalink structure is active. So, a bit of internal CSS can help alternatively, and the syntax is `in_page('page_slug')`: ``` <?php // Do action only on specific page in WP ?> <?php if( in_page('resourses') ) { ?> <style> #static-footer-image{ display: none; }...
107,557
<p>I'm using <a href="http://wordpress.org/plugins/taxonomy-images/" rel="nofollow">Taxonomy Images</a>, and I can't figure out how to display a category's associated image on a single.php. Essentailly, when a user is viewing a post that utilizes the single.php template, it should display the post's category's image. R...
[ { "answer_id": 107578, "author": "Lorenzo", "author_id": 33443, "author_profile": "https://wordpress.stackexchange.com/users/33443", "pm_score": 4, "selected": true, "text": "<p>I used this little trick to obtain the taxonomy image given the ID of the term:</p>\n\n<pre><code>&lt;?php\n ...
2013/07/23
[ "https://wordpress.stackexchange.com/questions/107557", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24566/" ]
I'm using [Taxonomy Images](http://wordpress.org/plugins/taxonomy-images/), and I can't figure out how to display a category's associated image on a single.php. Essentailly, when a user is viewing a post that utilizes the single.php template, it should display the post's category's image. Right now, it just doesn't dis...
I used this little trick to obtain the taxonomy image given the ID of the term: ``` <?php $images = get_option('taxonomy_image_plugin'); $img_url = wp_get_attachment_url( $images[$term_id] ); ?> ```
107,563
<p>I have a function that inserts a load of values into a database. Not a problem but I have a condition that changes the mysql statement. The problem is is the way wordpress constructs the statement, below is what I've tried...</p> <pre><code>public function sqlInsertTicket($event, $customer, $ticket){ $referenc...
[ { "answer_id": 107578, "author": "Lorenzo", "author_id": 33443, "author_profile": "https://wordpress.stackexchange.com/users/33443", "pm_score": 4, "selected": true, "text": "<p>I used this little trick to obtain the taxonomy image given the ID of the term:</p>\n\n<pre><code>&lt;?php\n ...
2013/07/23
[ "https://wordpress.stackexchange.com/questions/107563", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35683/" ]
I have a function that inserts a load of values into a database. Not a problem but I have a condition that changes the mysql statement. The problem is is the way wordpress constructs the statement, below is what I've tried... ``` public function sqlInsertTicket($event, $customer, $ticket){ $reference = 0; if...
I used this little trick to obtain the taxonomy image given the ID of the term: ``` <?php $images = get_option('taxonomy_image_plugin'); $img_url = wp_get_attachment_url( $images[$term_id] ); ?> ```
107,620
<p>My site cached by "wp-supper cache" plugin and "cloudflare.com"</p> <p>So my php function to count post views working incorrectly.</p> <p>I try to use ajax for it but I'm noob with JS code so I can not know where is wrong.</p> <p>In <strong>functions.php</strong> I create a simple function:</p> <pre><code>add_ac...
[ { "answer_id": 107641, "author": "iEmanuele", "author_id": 35646, "author_profile": "https://wordpress.stackexchange.com/users/35646", "pm_score": 3, "selected": true, "text": "<p>I've spotted some errors here:</p>\n\n<pre><code>jQuery.ajax({\n type: \"POST\",\n contentType: \"ap...
2013/07/24
[ "https://wordpress.stackexchange.com/questions/107620", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24865/" ]
My site cached by "wp-supper cache" plugin and "cloudflare.com" So my php function to count post views working incorrectly. I try to use ajax for it but I'm noob with JS code so I can not know where is wrong. In **functions.php** I create a simple function: ``` add_action('template_redirect', 'ajax_activation'); fu...
I've spotted some errors here: ``` jQuery.ajax({ type: "POST", contentType: "application/json; charset=utf-8", // default: 'application/x-www-form-urlencoded; charset=UTF-8'. you can not set url: "http://localhost/wp-admin/admin-ajax.php", // if you have correctly enabled ajax in wp, you should use the ...
107,622
<p>Is there a way to create a 'role' in WordPress for a guest? I am using a role visibility plugin which lets me choose the type of visibility to each role. However a Guest hasn't got a role. I can create a role, however not sure how to link this to the "Guest"...</p>
[ { "answer_id": 107623, "author": "user1627363", "author_id": 32731, "author_profile": "https://wordpress.stackexchange.com/users/32731", "pm_score": 0, "selected": false, "text": "<p>you can see 'guest' as a user role too actually. Anyhow, to get a guest, you can use this:</p>\n\n<pre><c...
2013/07/24
[ "https://wordpress.stackexchange.com/questions/107622", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35709/" ]
Is there a way to create a 'role' in WordPress for a guest? I am using a role visibility plugin which lets me choose the type of visibility to each role. However a Guest hasn't got a role. I can create a role, however not sure how to link this to the "Guest"...
Use add\_role with any array of capabilities. Example: ``` add_role( 'custom_role', 'Custom Role', array( 'read' => true ) ); ```
107,629
<p>I've developed two plugins in which one function is the same (same name, same functionality). When trying to activate both plugins Wordpress throws an error because it doesn't let me defining the function under the same name twice.</p> <p>Is there a way to make this function private for the plugin only, without usi...
[ { "answer_id": 107623, "author": "user1627363", "author_id": 32731, "author_profile": "https://wordpress.stackexchange.com/users/32731", "pm_score": 0, "selected": false, "text": "<p>you can see 'guest' as a user role too actually. Anyhow, to get a guest, you can use this:</p>\n\n<pre><c...
2013/07/24
[ "https://wordpress.stackexchange.com/questions/107629", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34939/" ]
I've developed two plugins in which one function is the same (same name, same functionality). When trying to activate both plugins Wordpress throws an error because it doesn't let me defining the function under the same name twice. Is there a way to make this function private for the plugin only, without using object ...
Use add\_role with any array of capabilities. Example: ``` add_role( 'custom_role', 'Custom Role', array( 'read' => true ) ); ```
107,633
<p>When I go to my homepage, <a href="http://example.com" rel="nofollow">http://example.com</a>, I <em>sometimes</em> get redirected to <a href="http://example.com/SXKSLW/" rel="nofollow">http://example.com/SXKSLW/</a> or some other random URL along that pattern that yields 404 page.</p> <p>I do not remember doing any...
[ { "answer_id": 107623, "author": "user1627363", "author_id": 32731, "author_profile": "https://wordpress.stackexchange.com/users/32731", "pm_score": 0, "selected": false, "text": "<p>you can see 'guest' as a user role too actually. Anyhow, to get a guest, you can use this:</p>\n\n<pre><c...
2013/07/24
[ "https://wordpress.stackexchange.com/questions/107633", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35717/" ]
When I go to my homepage, <http://example.com>, I *sometimes* get redirected to <http://example.com/SXKSLW/> or some other random URL along that pattern that yields 404 page. I do not remember doing anything special. Tried to disable most of the plugins (except the ones that are installed after the issue has been noti...
Use add\_role with any array of capabilities. Example: ``` add_role( 'custom_role', 'Custom Role', array( 'read' => true ) ); ```
107,656
<p>I have hundreds of art images in my WP media library, each of which I want to convert into a woocommerce product, and set as featured image of that product.</p> <p>Rather than manually adding new products and setting featured images, which would take days of repetitive work, is there a way to do this automatically ...
[ { "answer_id": 107809, "author": "Charles Clarkson", "author_id": 31788, "author_profile": "https://wordpress.stackexchange.com/users/31788", "pm_score": 0, "selected": false, "text": "<p>No. There is no command in MySQL that can convert an entry to a woocommerce product specific format....
2013/07/24
[ "https://wordpress.stackexchange.com/questions/107656", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35726/" ]
I have hundreds of art images in my WP media library, each of which I want to convert into a woocommerce product, and set as featured image of that product. Rather than manually adding new products and setting featured images, which would take days of repetitive work, is there a way to do this automatically in MySQL?
I'd agree that doing this in SQL would be a lot more to learn than PHP. With WordPress functions you can run a query on all the images ( [`WP_Query`](http://codex.wordpress.org/Class_Reference/WP_Query) ) and then loop through the results and use the info from the images to create a new post using `[wp_insert_post()][2...
107,660
<p>I can't seem to figure it out. No matter what I do, the ajax call keeps giving a 0 response. I've tested my PHP funtion and it works fine but whenever I call it through ajax I receive nothing (only a 0 response). Any help/suggestions is much appreciated.</p> <pre><code>add_action('wp_ajax_get_ldapattr', 'get_ldap_a...
[ { "answer_id": 107678, "author": "montrealist", "author_id": 8105, "author_profile": "https://wordpress.stackexchange.com/users/8105", "pm_score": 0, "selected": false, "text": "<p>The following works for me on my local WordPress install. Note that I hardcoded the AJAX URL, it will be di...
2013/07/24
[ "https://wordpress.stackexchange.com/questions/107660", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35727/" ]
I can't seem to figure it out. No matter what I do, the ajax call keeps giving a 0 response. I've tested my PHP funtion and it works fine but whenever I call it through ajax I receive nothing (only a 0 response). Any help/suggestions is much appreciated. ``` add_action('wp_ajax_get_ldapattr', 'get_ldap_attr'); add_act...
Debug it logically. This code works. I just tested it. This in a theme (I put it in header.php for testing): ``` jQuery(document).ready(function() { var lanid = 'demo'; var ajaxurl = '<?php echo admin_url("admin-ajax.php", null); ?>'; data = { action: "get_ldapattr", lanid: lanid}; jQuery.ajax({ ...
107,671
<p>Using Rilwis' Meta Box plugin for custom metaboxes, is there a way that I can load a metabox on all page templates <em>except</em> <code>template-home.php</code>? </p> <pre><code>'only_on' =&gt; array( 'template' =&gt; array( 'template-home.php' ), ), </code></pre> <p>I tried adding <code>!</code> before it b...
[ { "answer_id": 107675, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 0, "selected": false, "text": "<p>There is a homepage check you can use which would probably be easier than checking the template using <code>is_fro...
2013/07/24
[ "https://wordpress.stackexchange.com/questions/107671", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33310/" ]
Using Rilwis' Meta Box plugin for custom metaboxes, is there a way that I can load a metabox on all page templates *except* `template-home.php`? ``` 'only_on' => array( 'template' => array( 'template-home.php' ), ), ``` I tried adding `!` before it but it didn't work.
You could flip the `rw_maybe_include()` function around and create a `rw_maybe_exclude()` ``` /** * Check if meta boxes is included * * @return bool */ function rw_maybe_exlude( $conditions ) { // Include in back-end only if ( ! defined( 'WP_ADMIN' ) || ! WP_ADMIN ) { return true; } // Alw...
107,672
<p>I use the following function to get the latest comment for each one of my posts and display it on archive and index pages under the post content:</p> <pre><code>function kv_latest_comment($post){ $args = array( 'status' =&gt; 'approve', 'number' =&gt; '1', 'post_id' =&gt...
[ { "answer_id": 107690, "author": "Pontus Abrahamsson", "author_id": 16722, "author_profile": "https://wordpress.stackexchange.com/users/16722", "pm_score": 2, "selected": false, "text": "<p>Beacause you are not passing the post object, on a template you have the <code>$post</code>, but i...
2013/07/24
[ "https://wordpress.stackexchange.com/questions/107672", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33573/" ]
I use the following function to get the latest comment for each one of my posts and display it on archive and index pages under the post content: ``` function kv_latest_comment($post){ $args = array( 'status' => 'approve', 'number' => '1', 'post_id' => $post->ID, // use pos...
[`get_comment_date`](http://codex.wordpress.org/Function_Reference/get_comment_date) requires a comment id as the second argument. If you don't provide this, it looks to the global `$comment` variable, which is set when using a WP\_Query->the\_comment(). Maybe consider changing your loop to be a WP\_Query, or just do `...
107,686
<p>When you go to something like: site.com/?cat=2&amp;page=2</p> <p>you might see 3 posts, the page before might have 5 posts. I am looking for a way to count the posts on a given page. so if I am on page 2, with three posts, said function should return 3.</p> <p>any idea?</p>
[ { "answer_id": 107721, "author": "GGG", "author_id": 31267, "author_profile": "https://wordpress.stackexchange.com/users/31267", "pm_score": 0, "selected": false, "text": "<p>why not do a count?</p>\n\n<pre><code> &lt;?php count( $wp_query-&gt;posts ); ?&gt;\n</code></pre>\n" }, { ...
2013/07/24
[ "https://wordpress.stackexchange.com/questions/107686", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27670/" ]
When you go to something like: site.com/?cat=2&page=2 you might see 3 posts, the page before might have 5 posts. I am looking for a way to count the posts on a given page. so if I am on page 2, with three posts, said function should return 3. any idea?
The query object contains the member var `post_count` which will give you the number of posts on the current page: ``` $wp_query->post_count; ``` Also, for the total number of posts for the query (across all pages): ``` $wp_query->found_posts; ``` and the number of pages in the query: ``` $wp_query->max_num_page...
107,709
<p>I've got Wordpress running on WAMP. For some reason, when I check for updates to the core and to my plugins, it tells me that everything is up to date, even though I know that I am one version behind on the core and on three plugins. Why am I not picking up these updates?</p> <p>I checked file permissions, and they...
[ { "answer_id": 109914, "author": "Puggan Se", "author_id": 36573, "author_profile": "https://wordpress.stackexchange.com/users/36573", "pm_score": 1, "selected": false, "text": "<p>\"Download failed.\" comes from failing the <code>download_url()</code></p>\n\n<p>can you try running this ...
2013/07/24
[ "https://wordpress.stackexchange.com/questions/107709", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21290/" ]
I've got Wordpress running on WAMP. For some reason, when I check for updates to the core and to my plugins, it tells me that everything is up to date, even though I know that I am one version behind on the core and on three plugins. Why am I not picking up these updates? I checked file permissions, and they're all go...
I use XAMPP myself, but WAMP isn't much different. I'll bet you have not enabled the curl module. WordPress can use other methods (streams and fsockopen) as a fallback, but these may be disabled by default as well in a stock install. Curl is preferred and easy to enable. 1. Close WAMP 2. Go your the \bin\php\version...
107,713
<p>In my plugin, I need to find any posts of a custom post type that have a certain title. I was using this:</p> <pre><code>$my_post = get_page_by_title( $title, OBJECT, 'my_custom_post_type' ); </code></pre> <p>This works great, but if there is more than one post with the same title, get_page_by_title will only ret...
[ { "answer_id": 107718, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 4, "selected": true, "text": "<p>You will need to create a new function. My example is a fork of the core function. The following will allow...
2013/07/24
[ "https://wordpress.stackexchange.com/questions/107713", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32110/" ]
In my plugin, I need to find any posts of a custom post type that have a certain title. I was using this: ``` $my_post = get_page_by_title( $title, OBJECT, 'my_custom_post_type' ); ``` This works great, but if there is more than one post with the same title, get\_page\_by\_title will only return one result. Accordin...
You will need to create a new function. My example is a fork of the core function. The following will allow you to create a query across all published posts regardless of post\_type, unless you desire that specific set. ``` function get_posts_by_title($page_title, $post_type = false, $output = OBJECT ) { global $w...
107,719
<p>I've created a new custom post type for a specific posts. The posts from my new custom post type, have - by default - set the comments to "off". I need to the comments to be "on" by default.</p> <p>In my <code>functions.php</code> file I have this:</p> <pre><code>'supports' =&gt; array('editor','comments') </code>...
[ { "answer_id": 107724, "author": "kel", "author_id": 2832, "author_profile": "https://wordpress.stackexchange.com/users/2832", "pm_score": 2, "selected": true, "text": "<p>Custom post types support comments by default. I'm not sure how you registered your post type since you didn't inclu...
2013/07/24
[ "https://wordpress.stackexchange.com/questions/107719", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35508/" ]
I've created a new custom post type for a specific posts. The posts from my new custom post type, have - by default - set the comments to "off". I need to the comments to be "on" by default. In my `functions.php` file I have this: ``` 'supports' => array('editor','comments') ``` and ``` function default_comments_...
Custom post types support comments by default. I'm not sure how you registered your post type since you didn't include the full source but the [codex has good examples](http://codex.wordpress.org/Function_Reference/register_post_type) on how to do that. If the metabox is showing in your custom post type and you are tr...
107,761
<p>I am trying to use jQuery to scroll the div content vertically.</p> <p>I have used the following line of code in <code>function.php</code></p> <pre><code>add_action( 'wp_enquque_scripts', 'my_script_enqueue' ); function my_script_enqueue() { wp_enqueue_script( 'my-jquery', '/wordpress/wp-content/themes/MyThem...
[ { "answer_id": 107745, "author": "excessive34", "author_id": 35640, "author_profile": "https://wordpress.stackexchange.com/users/35640", "pm_score": 0, "selected": false, "text": "<p>You can accomplish this by using \"Custom-Fields\" within each post.</p>\n\n<p>Essentially, you set a cus...
2013/07/25
[ "https://wordpress.stackexchange.com/questions/107761", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35772/" ]
I am trying to use jQuery to scroll the div content vertically. I have used the following line of code in `function.php` ``` add_action( 'wp_enquque_scripts', 'my_script_enqueue' ); function my_script_enqueue() { wp_enqueue_script( 'my-jquery', '/wordpress/wp-content/themes/MyTheme/js/jquery-1.9.0.js', array( 'j...
You can simply use the featured image. Just output it where you want it to appear `<?php the_post_thumbnail( $size, $attr ); ?>` Use accordingly a class or a ID to style it with CSS. Take a look there: <https://codex.wordpress.org/Post_Thumbnails> to abilitate the featured image in your theme.
107,768
<p>I have nearly 1500 posts in my wordpress blog. Before moving to a new design, I need to tag all these posts with one tag 'old'. How can I do this? I tried to bulk edit posts and it will always go only upto 78 posts every time I tried. I tried increasing server limits and still it won't work! How can I do this?</p>
[ { "answer_id": 107776, "author": "ManuA", "author_id": 35775, "author_profile": "https://wordpress.stackexchange.com/users/35775", "pm_score": 0, "selected": false, "text": "<p>Please try this</p>\n\n<pre>\n<code>\n global $post;\n $args = array( 'posts_per_page' => -1);\n $myposts...
2013/07/25
[ "https://wordpress.stackexchange.com/questions/107768", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14404/" ]
I have nearly 1500 posts in my wordpress blog. Before moving to a new design, I need to tag all these posts with one tag 'old'. How can I do this? I tried to bulk edit posts and it will always go only upto 78 posts every time I tried. I tried increasing server limits and still it won't work! How can I do this?
If you have the ability to use [wp-cli](http://wp-cli.org) on a bash-like shell it's a handy way to do this: ``` for ID in $(wp post list --post_type=post --post_status=any --field=ID); do wp post term add $ID post_tag old; done ``` * `for ID in $(…); do` starts a loop for each line of output of the internal command...
107,775
<p>I am using Advanced Custom Fields in my WordPress project. In it I have added 2 datepickers as custom fields for pages.</p> <p>Now the main problem is whenever I add a new page both datepickers by default show up empty, but I want to set the current date of the server as a default, that is whenever I add a new page...
[ { "answer_id": 107800, "author": "Anatol Bivol", "author_id": 34944, "author_profile": "https://wordpress.stackexchange.com/users/34944", "pm_score": 1, "selected": true, "text": "<p>It depends on the datepicker plugin you are using. Mostly all datepickers will have a default value you c...
2013/07/25
[ "https://wordpress.stackexchange.com/questions/107775", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35776/" ]
I am using Advanced Custom Fields in my WordPress project. In it I have added 2 datepickers as custom fields for pages. Now the main problem is whenever I add a new page both datepickers by default show up empty, but I want to set the current date of the server as a default, that is whenever I add a new page both the ...
It depends on the datepicker plugin you are using. Mostly all datepickers will have a default value you can play with. Usualy it is set within the input text type that hosts the datepicker. ``` <input type="text" class="datepicker" default-value="2013/07/25"> ``` And in wordpress' php you can do : ``` <input type="...
107,778
<p>I am using a <code>quicktags</code> plugin, which was not loading on the home page, now it does, but it does it on the wrong place. How can I solve this?</p> <p><strong>I want the quicktags.min.js file to load first, rather than the basic-comment quicktags...</strong></p> <p>I am using this script:</p> <pre><code...
[ { "answer_id": 107800, "author": "Anatol Bivol", "author_id": 34944, "author_profile": "https://wordpress.stackexchange.com/users/34944", "pm_score": 1, "selected": true, "text": "<p>It depends on the datepicker plugin you are using. Mostly all datepickers will have a default value you c...
2013/07/25
[ "https://wordpress.stackexchange.com/questions/107778", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34977/" ]
I am using a `quicktags` plugin, which was not loading on the home page, now it does, but it does it on the wrong place. How can I solve this? **I want the quicktags.min.js file to load first, rather than the basic-comment quicktags...** I am using this script: ``` add_action( 'wp_enqueue_scripts', 'ron_scripts' ); ...
It depends on the datepicker plugin you are using. Mostly all datepickers will have a default value you can play with. Usualy it is set within the input text type that hosts the datepicker. ``` <input type="text" class="datepicker" default-value="2013/07/25"> ``` And in wordpress' php you can do : ``` <input type="...
107,781
<p>I want the remove wpautop filter working only on posts from my blog. Because at some pages i need the autop, and at some pages i need it to not be there.</p> <p>I use the following rule and it is in my theme's functions.php:</p> <pre><code>remove_filter( 'the_content', 'wpautop' ); </code></pre> <p>Because I only...
[ { "answer_id": 107784, "author": "Maartje", "author_id": 34616, "author_profile": "https://wordpress.stackexchange.com/users/34616", "pm_score": 0, "selected": false, "text": "<p>I found it.</p>\n\n<p>Really simple.</p>\n\n<p>I just added the remove filter rule at the top of my document,...
2013/07/25
[ "https://wordpress.stackexchange.com/questions/107781", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34616/" ]
I want the remove wpautop filter working only on posts from my blog. Because at some pages i need the autop, and at some pages i need it to not be there. I use the following rule and it is in my theme's functions.php: ``` remove_filter( 'the_content', 'wpautop' ); ``` Because I only want it on blogposts I was think...
Generally it's not a common way to strip wpautop with remove\_filter as it is native functionality of WordPress. But if you want to : place the remove\_filter() function right before the the\_content() function on the pages/templates where you don't need the wpautop `<?php remove_filter( 'the_content', 'wpautop' ); t...
107,816
<p>I'm trying to create mobile-friendly version for a wp site. I'm using the "any mobile theme switcher" to switch to an alternative (mobile) theme which works well.</p> <p>I have also created some alternative key pages (home, contact &amp; news) which are heavily edited (shorter) versions of the desktop theme content...
[ { "answer_id": 107819, "author": "Pontus Abrahamsson", "author_id": 16722, "author_profile": "https://wordpress.stackexchange.com/users/16722", "pm_score": 1, "selected": false, "text": "<p>You can make a simple function for this, check if is mobile (<a href=\"http://codex.wordpress.org/...
2013/07/25
[ "https://wordpress.stackexchange.com/questions/107816", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22537/" ]
I'm trying to create mobile-friendly version for a wp site. I'm using the "any mobile theme switcher" to switch to an alternative (mobile) theme which works well. I have also created some alternative key pages (home, contact & news) which are heavily edited (shorter) versions of the desktop theme content and added the...
I cobbled together the following code from Pontus's answer and the answer to a slightly different problem here on WP Answers - This works alongside my mobile theme switching plugin, so when a mobile user visits the site, they are redirected to a new set of "mobile-friendly" pages and see my new responsive mobile theme,...
107,817
<p>This comes from the <code>footer.php</code> file of a wordpress theme I would like to modify. I want one of five images to load on refresh instead of <code>1.jpg</code> every time. </p> <pre><code>&lt;script type="text/javascript"&gt; &lt;?php if((is_archive()) || (is_author()) || (is_category()) || (is_home()) |...
[ { "answer_id": 107825, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 1, "selected": false, "text": "<ol>\n<li>That theme should not be using the <code>$</code> alias as WordPress loads\njQuery in <a href=\"http:...
2013/07/25
[ "https://wordpress.stackexchange.com/questions/107817", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35784/" ]
This comes from the `footer.php` file of a wordpress theme I would like to modify. I want one of five images to load on refresh instead of `1.jpg` every time. ``` <script type="text/javascript"> <?php if((is_archive()) || (is_author()) || (is_category()) || (is_home()) || (is_single()) || (is_tag()) || ($posttype =...
1. That theme should not be using the `$` alias as WordPress loads jQuery in ["No Conflict" mode](http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_Wrappers). 2. I can only assume the theme is loading its own jQuery, which is pretty bad form. 3. The theme should really be [registering](h...
107,821
<p>I have a small website that wants a different sidebar for each page containing blocks of text, blocks of images, and blocks of links, etc. What I'm trying to do is register a sidebar for each top level page:</p> <pre><code>if ( function_exists('register_sidebar') ){ $topLevel = get_pages(array( 'sort_co...
[ { "answer_id": 107825, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 1, "selected": false, "text": "<ol>\n<li>That theme should not be using the <code>$</code> alias as WordPress loads\njQuery in <a href=\"http:...
2013/07/25
[ "https://wordpress.stackexchange.com/questions/107821", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7355/" ]
I have a small website that wants a different sidebar for each page containing blocks of text, blocks of images, and blocks of links, etc. What I'm trying to do is register a sidebar for each top level page: ``` if ( function_exists('register_sidebar') ){ $topLevel = get_pages(array( 'sort_column' => 'po...
1. That theme should not be using the `$` alias as WordPress loads jQuery in ["No Conflict" mode](http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_Wrappers). 2. I can only assume the theme is loading its own jQuery, which is pretty bad form. 3. The theme should really be [registering](h...
107,828
<p>Since I frequently update posts so it’s crucial for me to display last modified date instead of post published date like following image. Its because I want search engine to display my post last modified date not post published date. Can anyone help me regarding this issue any help would be appreciated.</p> <p><img...
[ { "answer_id": 107825, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 1, "selected": false, "text": "<ol>\n<li>That theme should not be using the <code>$</code> alias as WordPress loads\njQuery in <a href=\"http:...
2013/07/25
[ "https://wordpress.stackexchange.com/questions/107828", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19942/" ]
Since I frequently update posts so it’s crucial for me to display last modified date instead of post published date like following image. Its because I want search engine to display my post last modified date not post published date. Can anyone help me regarding this issue any help would be appreciated. ![enter image ...
1. That theme should not be using the `$` alias as WordPress loads jQuery in ["No Conflict" mode](http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_Wrappers). 2. I can only assume the theme is loading its own jQuery, which is pretty bad form. 3. The theme should really be [registering](h...
107,843
<p><strong>EDIT</strong></p> <p>Answer was found here: <a href="https://wordpress.stackexchange.com/questions/117546/is-active-sidebar-always-returns-false">is_active_sidebar() Always Returns False</a></p> <p>By user: <code>s_ha_dum</code></p> <hr> <p>I'm dynamically creating sidebars and registering them for every...
[ { "answer_id": 107825, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 1, "selected": false, "text": "<ol>\n<li>That theme should not be using the <code>$</code> alias as WordPress loads\njQuery in <a href=\"http:...
2013/07/25
[ "https://wordpress.stackexchange.com/questions/107843", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7355/" ]
**EDIT** Answer was found here: [is\_active\_sidebar() Always Returns False](https://wordpress.stackexchange.com/questions/117546/is-active-sidebar-always-returns-false) By user: `s_ha_dum` --- I'm dynamically creating sidebars and registering them for every top level page: [Dynamically Register Sidebars For Each ...
1. That theme should not be using the `$` alias as WordPress loads jQuery in ["No Conflict" mode](http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_Wrappers). 2. I can only assume the theme is loading its own jQuery, which is pretty bad form. 3. The theme should really be [registering](h...
107,856
<p>I have sourced the following <a href="https://wordpress.stackexchange.com/questions/25808/setting-a-posts-featured-image-from-an-embedded-youtube-video">code</a> which captures the URL for a YouTube video placed in the content/body the code then gets the video image from YouTube and sets the image as a featured imag...
[ { "answer_id": 107859, "author": "Chozen", "author_id": 35798, "author_profile": "https://wordpress.stackexchange.com/users/35798", "pm_score": -1, "selected": false, "text": "<p>The easiest way to achieve this is using the <a href=\"http://wordpress.org/plugins/video-thumbnails/\" rel=\...
2013/07/26
[ "https://wordpress.stackexchange.com/questions/107856", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17073/" ]
I have sourced the following [code](https://wordpress.stackexchange.com/questions/25808/setting-a-posts-featured-image-from-an-embedded-youtube-video) which captures the URL for a YouTube video placed in the content/body the code then gets the video image from YouTube and sets the image as a featured image. ``` fu...
``` function set_youtube_as_featured_image($post_id) { if( has_post_thumbnail($post_id) ) return; $url = get_post_meta($post_id, 'ci_cpt_video_link', true); if ( $url && filter_var($url, FILTER_VALIDATE_URL) ) { // getting thumb url from video url parse_str( parse_url( $url, PHP_URL_QUERY ), $youtub...
107,860
<p>I'm working on a function.php file for a new theme system. I need to know how to make a custom template executable through a URL. So if someone were to go to <code>http://website.com/my-custom-template/</code> how can I make it so that page that loads reads from the template <code>my-custom-template.php</code> in th...
[ { "answer_id": 107864, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 0, "selected": false, "text": "<p>This is a bit tricky, and while possible, I'd recommend <em>not</em> doing this. It's not how WordPress is designe...
2013/07/26
[ "https://wordpress.stackexchange.com/questions/107860", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29073/" ]
I'm working on a function.php file for a new theme system. I need to know how to make a custom template executable through a URL. So if someone were to go to `http://website.com/my-custom-template/` how can I make it so that page that loads reads from the template `my-custom-template.php` in the themes folder?
You can use wordpress templates to load for a particular page. just create a template file with any name ( place template definition in file i.e commented code to declare a template) and select it as a template while adding a page. in this way file will be loaded automatically for page and you can use that template for...
107,905
<p>I wrote a little wordpress plugin and I want to grant only specific roles or users access to it. Is there a way to do this?</p>
[ { "answer_id": 107908, "author": "mtuttle", "author_id": 35190, "author_profile": "https://wordpress.stackexchange.com/users/35190", "pm_score": 1, "selected": false, "text": "<p>Are you looking for something like this? </p>\n\n<p><a href=\"http://wp.tutsplus.com/articles/quick-tip-user-...
2013/07/26
[ "https://wordpress.stackexchange.com/questions/107905", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11981/" ]
I wrote a little wordpress plugin and I want to grant only specific roles or users access to it. Is there a way to do this?
Here how register a role specifically for a plugin and add plugin specific capabilities to selected core roles ``` function my_plugin_install() { // add a new role for plugin with some capabilities add_role('my_plugin_role', 'My Plugin Role', array( 'manage_my_plugin' => true, // plugin specific capability ...
107,907
<p>I am using <code>&lt;?php comments_template(); ?&gt;</code> to show my comment form and I'm trying to remove the url field so I added this to my functions</p> <pre><code>add_filter('comment_form_default_fields', 'clear_url_box'); function clear_url_box($fields){ if(isset($fields['url'])) unset($fields['url'...
[ { "answer_id": 107914, "author": "mtuttle", "author_id": 35190, "author_profile": "https://wordpress.stackexchange.com/users/35190", "pm_score": 2, "selected": true, "text": "<p>Your theme should have a comments.php file. Can you just remove the field there? For instance, my comments.p...
2013/07/26
[ "https://wordpress.stackexchange.com/questions/107907", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17971/" ]
I am using `<?php comments_template(); ?>` to show my comment form and I'm trying to remove the url field so I added this to my functions ``` add_filter('comment_form_default_fields', 'clear_url_box'); function clear_url_box($fields){ if(isset($fields['url'])) unset($fields['url']); return $fields; } ``` ...
Your theme should have a comments.php file. Can you just remove the field there? For instance, my comments.php files has the following code: ``` <p class="field"><label for="url"><?php _e('Website', 'theme1721'); ?> </label><input type="text" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>...
107,910
<p>All of the answers I've found so far - here and elsewhere - involve creating a (custom) post - which would be 'overkill' because in this instance many of the 'terms' would only appear once.</p> <p>Specific example to explain what I'm trying to accomplish:</p> <pre><code>Person A may be the composer of Song 1; Pers...
[ { "answer_id": 107923, "author": "Angela", "author_id": 28229, "author_profile": "https://wordpress.stackexchange.com/users/28229", "pm_score": 0, "selected": false, "text": "<p>So here is the thing with a structure like this. It goes both ways. Person A can be the composer of poem 1, an...
2013/07/26
[ "https://wordpress.stackexchange.com/questions/107910", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35811/" ]
All of the answers I've found so far - here and elsewhere - involve creating a (custom) post - which would be 'overkill' because in this instance many of the 'terms' would only appear once. Specific example to explain what I'm trying to accomplish: ``` Person A may be the composer of Song 1; Person A may be the lyric...
Using standard Wordpress functionalities this is, simply, not possible, unless using complicated and poorly performing tricks. The method I suggest you is to create your custom table where store relationship. It should consists of 5 columns: ``` person_id | post_id | post_type | taxonomy | term_id ``` Now, copying...
107,918
<p>I am new to programming and WordPress.</p> <p>I am working on a project where I am using a custom taxonomy (tag). When I select my tag in the admin panel (post), it automatically gets arranged in alphabetical order.</p> <p>I'd like to stop that behavior, as I want to display the tags in the order I selected them.<...
[ { "answer_id": 107921, "author": "Anatol Bivol", "author_id": 34944, "author_profile": "https://wordpress.stackexchange.com/users/34944", "pm_score": 0, "selected": false, "text": "<p>When displaying categories you should use </p>\n\n<pre><code>&lt;?php wp_list_categories(array('orderby'...
2013/07/26
[ "https://wordpress.stackexchange.com/questions/107918", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34354/" ]
I am new to programming and WordPress. I am working on a project where I am using a custom taxonomy (tag). When I select my tag in the admin panel (post), it automatically gets arranged in alphabetical order. I'd like to stop that behavior, as I want to display the tags in the order I selected them.
Here you go: just place this in your functions.php: ``` /** * Sort post_tags by term_order * * @param array $terms array of objects to be replaced with sorted list * @param integer $id post id * @param string $taxonomy only 'post_tag' is changed. * @return array of objects */ function plugin_get_the_ordered_ter...
107,920
<p>I have a snippet that creates an option in Settings->General using Settings API. However, the values don't get updated and I was wondering if anyone can help point out the problem with the following code </p> <pre><code>function admin_init_callback() { register_setting( 'msp_settings', 'msp_duration' ); ...
[ { "answer_id": 107921, "author": "Anatol Bivol", "author_id": 34944, "author_profile": "https://wordpress.stackexchange.com/users/34944", "pm_score": 0, "selected": false, "text": "<p>When displaying categories you should use </p>\n\n<pre><code>&lt;?php wp_list_categories(array('orderby'...
2013/07/26
[ "https://wordpress.stackexchange.com/questions/107920", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28229/" ]
I have a snippet that creates an option in Settings->General using Settings API. However, the values don't get updated and I was wondering if anyone can help point out the problem with the following code ``` function admin_init_callback() { register_setting( 'msp_settings', 'msp_duration' ); add_settings_se...
Here you go: just place this in your functions.php: ``` /** * Sort post_tags by term_order * * @param array $terms array of objects to be replaced with sorted list * @param integer $id post id * @param string $taxonomy only 'post_tag' is changed. * @return array of objects */ function plugin_get_the_ordered_ter...
107,939
<p>Very confused why the following code does not work. </p> <pre><code>function discount_State() { if(is_page('cart')){ global $wpdb; $current_user = wp_get_current_user(); $need = $current_user-&gt;ID; $getID = $wpdb-&gt;get_var($wpdb-&gt;prepare("SELECT meta_value from table where user_id = $need AND meta_key = ...
[ { "answer_id": 107941, "author": "Ben Racicot", "author_id": 18726, "author_profile": "https://wordpress.stackexchange.com/users/18726", "pm_score": 0, "selected": false, "text": "<p>I can't test your code but this is how I used inline PHP variables to work on some of my SQL in the past....
2013/07/26
[ "https://wordpress.stackexchange.com/questions/107939", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31468/" ]
Very confused why the following code does not work. ``` function discount_State() { if(is_page('cart')){ global $wpdb; $current_user = wp_get_current_user(); $need = $current_user->ID; $getID = $wpdb->get_var($wpdb->prepare("SELECT meta_value from table where user_id = $need AND meta_key = 'shipping_state'")); e...
You're not using `prepare` correctly, refer to [the codex](http://codex.wordpress.org/Class_Reference/wpdb#Protect_Queries_Against_SQL_Injection_Attacks) for an example. ``` $wpdb->get_var( $wpdb->prepare( " SELECT meta_value FROM table WHERE user_id = %d AND meta_key = 'shipping_s...
107,949
<p>How would I go about returning two JSON objects with one AJAX call and PHP function? Any help is much appreciated!</p> <p>Here's the PHP function:</p> <pre><code>function get_ldap_attr() { header("Content-type: application/json"); $lan = $_POST['lan']; $dn = get_site_option ( "ldapServerOU" ); $usr...
[ { "answer_id": 107951, "author": "M-R", "author_id": 17061, "author_profile": "https://wordpress.stackexchange.com/users/17061", "pm_score": 3, "selected": true, "text": "<p>If I get it correctly, You need to wrap them in an array and pass to Javascript. </p>\n\n<pre><code>function get_l...
2013/07/26
[ "https://wordpress.stackexchange.com/questions/107949", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35727/" ]
How would I go about returning two JSON objects with one AJAX call and PHP function? Any help is much appreciated! Here's the PHP function: ``` function get_ldap_attr() { header("Content-type: application/json"); $lan = $_POST['lan']; $dn = get_site_option ( "ldapServerOU" ); $usr = get_site_option ( ...
If I get it correctly, You need to wrap them in an array and pass to Javascript. ``` function get_ldap_attr() { header("Content-type: application/json"); ... // suppose you want to return $second_var echo json_encode(array($sup,$second_var)); die(); } ``` Success function of JSON request will...
107,952
<p>I would like some help with the following issue with woocommerce.</p> <p>I am using wordpress 3.5.2, woocommerce 2.0.13 and sommerce theme.</p> <p>I have a product category page, in which I display 5 subcategories. <strong>Under</strong> the 5 subcategory images, I would like to have some featured products or rand...
[ { "answer_id": 107967, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 2, "selected": false, "text": "<p>I just double checked and WooCommerce runs the product category description through <code>the_content</c...
2013/07/26
[ "https://wordpress.stackexchange.com/questions/107952", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35824/" ]
I would like some help with the following issue with woocommerce. I am using wordpress 3.5.2, woocommerce 2.0.13 and sommerce theme. I have a product category page, in which I display 5 subcategories. **Under** the 5 subcategory images, I would like to have some featured products or random products of these categorie...
I just double checked and WooCommerce runs the product category description through `the_content` filters, which means that it should run shortcodes. WooCommerce has plenty of shortcodes, [see their documentation](http://docs.woothemes.com/document/woocommerce-shortcodes/) Including featured products: ``` [featured_...
107,998
<p>I am new to wordpress, and have encountered some difficulty in making my own custom layouts. I'm using _S framework (underscore.me) as well as Custom Post Templates plugin. </p> <p>I'm using custom fields to inject images above the title of posts currently, and that's worked so far but I encounter problems when try...
[ { "answer_id": 128464, "author": "RachieVee", "author_id": 42783, "author_profile": "https://wordpress.stackexchange.com/users/42783", "pm_score": 2, "selected": false, "text": "<p>To rephrase, I believe what you're asking is how can you have a different style or template for your custom...
2013/07/27
[ "https://wordpress.stackexchange.com/questions/107998", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35313/" ]
I am new to wordpress, and have encountered some difficulty in making my own custom layouts. I'm using \_S framework (underscore.me) as well as Custom Post Templates plugin. I'm using custom fields to inject images above the title of posts currently, and that's worked so far but I encounter problems when trying to ma...
To rephrase, I believe what you're asking is how can you have a different style or template for your custom post types when they are displaying as a list? It looks like the Custom Post Templates plugin you're using only allows you to switch templates for the single view of a post, not the listing of the posts, which i...
108,008
<p>I have som problems with the date functions in wordpress.</p> <p>I am trying to get different format on the post date on some pages and i have been trying "the_date()","the_time()" and "echo get_the_date()". They all behave in the same way.</p> <p>They output the correct date format when i just type for example th...
[ { "answer_id": 108027, "author": "JMau", "author_id": 31376, "author_profile": "https://wordpress.stackexchange.com/users/31376", "pm_score": 1, "selected": false, "text": "<p>When using date function it is recommanded to use date format or time format of the installation :</p>\n\n<pre><...
2013/07/27
[ "https://wordpress.stackexchange.com/questions/108008", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35843/" ]
I have som problems with the date functions in wordpress. I am trying to get different format on the post date on some pages and i have been trying "the\_date()","the\_time()" and "echo get\_the\_date()". They all behave in the same way. They output the correct date format when i just type for example the\_time(). Th...
When using date function it is recommanded to use date format or time format of the installation : ``` get_option('time_format'); get_option('date_format'); ``` This allows you to grab date format or time format of the current installation.
108,034
<p>I am trying to make a custom grid for my Wordpress posts. I have been searching the web however all the tutorials I have found utilize a column method where it just alternates between the columns. For what I am doing that would be impossible I need it to actually count off six thumbnails and then return a line and d...
[ { "answer_id": 108027, "author": "JMau", "author_id": 31376, "author_profile": "https://wordpress.stackexchange.com/users/31376", "pm_score": 1, "selected": false, "text": "<p>When using date function it is recommanded to use date format or time format of the installation :</p>\n\n<pre><...
2013/07/27
[ "https://wordpress.stackexchange.com/questions/108034", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35551/" ]
I am trying to make a custom grid for my Wordpress posts. I have been searching the web however all the tutorials I have found utilize a column method where it just alternates between the columns. For what I am doing that would be impossible I need it to actually count off six thumbnails and then return a line and do i...
When using date function it is recommanded to use date format or time format of the installation : ``` get_option('time_format'); get_option('date_format'); ``` This allows you to grab date format or time format of the current installation.
108,036
<p>Someone knows why this happens?</p> <p>For instance, I have a post called <code>1987</code>, but it does not open it when I click on the link. When I use a different permalink structure, it opens it. Why is this and how can I solve this?</p> <p>FYI: <strong>I don't get a</strong> <code>404 error</code>, I just get...
[ { "answer_id": 117181, "author": "Nathan Mickler", "author_id": 39181, "author_profile": "https://wordpress.stackexchange.com/users/39181", "pm_score": 0, "selected": false, "text": "<p>You can solve this by updating the post's slug to something besides a number. Other than that, I have...
2013/07/27
[ "https://wordpress.stackexchange.com/questions/108036", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34977/" ]
Someone knows why this happens? For instance, I have a post called `1987`, but it does not open it when I click on the link. When I use a different permalink structure, it opens it. Why is this and how can I solve this? FYI: **I don't get a** `404 error`, I just get a Firefox error where it says: **this page is not r...
Sorry I didn't follow up on this. You mentioned you weren't using date archives. You can change the date archive structure to remove the conflict with `/%postname%/`: ``` function wpa_change_date_structure(){ global $wp_rewrite; $wp_rewrite->date_structure = 'date/%year%/%monthnum%/%day%'; } add_action( 'init'...
108,038
<p>I have this function:</p> <pre><code>&lt;?php $popular = new WP_Query('orderby=comment_count&amp;posts_per_page=5'); ?&gt; &lt;?php while ($popular-&gt;have_posts()) : $popular-&gt;the_post(); ?&gt; &lt;li&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt; &lt;/li&gt; ...
[ { "answer_id": 108045, "author": "Nathan Powell", "author_id": 27196, "author_profile": "https://wordpress.stackexchange.com/users/27196", "pm_score": 3, "selected": true, "text": "<p>Try this:</p>\n\n<pre><code>&lt;?php $popular = new WP_Query('orderby=comment_count&amp;posts_per_page=5...
2013/07/27
[ "https://wordpress.stackexchange.com/questions/108038", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34977/" ]
I have this function: ``` <?php $popular = new WP_Query('orderby=comment_count&posts_per_page=5'); ?> <?php while ($popular->have_posts()) : $popular->the_post(); ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> </li> <?php endwhile; ?> ``` Where I added `$popular->wp_comment_count`, but...
Try this: ``` <?php $popular = new WP_Query('orderby=comment_count&posts_per_page=5'); ?> <?php while ($popular->have_posts()) : $popular->the_post(); ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> has <?php comments_number( 'no responses', 'one response', '% responses' ); ?>.</li> <?php endw...
108,066
<p>I have this little piece of php.</p> <pre><code>$attr = array( 'class' =&gt; 'bigImg', 'alt' =&gt; trim(strip_tags( $attachment-&gt;post_excerpt )), 'title' =&gt; trim(strip_tags( $attachment-&gt;post_title )) ); </code></pre> <p>I have this in the html:</p> <pre><code>&lt;?php...
[ { "answer_id": 108068, "author": "pixeline", "author_id": 82, "author_profile": "https://wordpress.stackexchange.com/users/82", "pm_score": 0, "selected": false, "text": "<p>Question is: where does <code>$attachment</code> comes from in your code. </p>\n\n<p>Also, i think you are looking...
2013/07/28
[ "https://wordpress.stackexchange.com/questions/108066", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35858/" ]
I have this little piece of php. ``` $attr = array( 'class' => 'bigImg', 'alt' => trim(strip_tags( $attachment->post_excerpt )), 'title' => trim(strip_tags( $attachment->post_title )) ); ``` I have this in the html: ``` <?php echo the_post_thumbnail( 'featured', $attr ); ?> ``` ...
**1.** [`the_post_thumbnail`](http://codex.wordpress.org/Function_Reference/the_post_thumbnail)... ... is a wrapper for [`echo get_the_post_thumbnail`](http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail). Hence the `echo` construct you are using is redundant. That's not the core of your problem, but ...
108,083
<p>I am creating a Wordpress page where all my posts in the child categories of team are displayed in a grid. I got this working with the below code. The formatting and general layout is great however it only shows the 5 most recent posts in the child category instead of all of them. In my Wordpress account I have 7 po...
[ { "answer_id": 108074, "author": "Morgan Estes", "author_id": 26317, "author_profile": "https://wordpress.stackexchange.com/users/26317", "pm_score": 2, "selected": false, "text": "<p>If she has <a href=\"http://en.support.wordpress.com/post-by-email/\" rel=\"nofollow\">Post by email</a>...
2013/07/28
[ "https://wordpress.stackexchange.com/questions/108083", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35551/" ]
I am creating a Wordpress page where all my posts in the child categories of team are displayed in a grid. I got this working with the below code. The formatting and general layout is great however it only shows the 5 most recent posts in the child category instead of all of them. In my Wordpress account I have 7 posts...
She could install a plugin like [DJ Email Publish](https://wordpress.org/plugins/dj-email-publish/) on her self-hosted blog. This will republish any post she creates to any blog that accepts e-mail posts. This will allow her to write a post using any method she chooses on the self-hosted blog, and it will reappear on h...
108,092
<p>Is this possible?</p> <p>I want to add different classes to the anchors, so not the same on all anchors. How can I do this? </p> <p>PS: I am using this:</p> <pre><code>function add_nav_class($output) { $output= preg_replace('/&lt;a/', '&lt;a class="your-class"', $output, 1); return $output; } add_filter('...
[ { "answer_id": 108183, "author": "Krzysiek Dróżdż", "author_id": 34172, "author_profile": "https://wordpress.stackexchange.com/users/34172", "pm_score": 3, "selected": true, "text": "<p>Yes, it is possible.</p>\n\n<p>You can achieve this using <code>wp_nav_menu_objects</code> filter.</p>...
2013/07/28
[ "https://wordpress.stackexchange.com/questions/108092", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34977/" ]
Is this possible? I want to add different classes to the anchors, so not the same on all anchors. How can I do this? PS: I am using this: ``` function add_nav_class($output) { $output= preg_replace('/<a/', '<a class="your-class"', $output, 1); return $output; } add_filter('wp_nav_menu', 'add_nav_class'); `...
Yes, it is possible. You can achieve this using `wp_nav_menu_objects` filter. ``` function my_wp_nav_menu_objects($objects, $args) { foreach($objects as $key => $item) { $objects[$key]->classes[] = 'my-class'; } return $objects; } add_filter('wp_nav_menu_objects', 'my_wp_nav_menu_objects', 10, 2);...
108,099
<p>I am using the SimpleReach plugin that adds some content to every post using the content hook. The content that is being added is</p> <pre><code>&lt;!-- SimpleReach Slide Plugin Version: {{srslide_plugin_version}} --&gt; &lt;script type='text/javascript' id='simplereach-slide-tag'&gt; __reach_config = { p...
[ { "answer_id": 108100, "author": "Alex Dumitru", "author_id": 5810, "author_profile": "https://wordpress.stackexchange.com/users/5810", "pm_score": 0, "selected": false, "text": "<p>I don't think you can setup autop like this. </p>\n\n<p>The only idea that comes to my mind is to set a po...
2013/07/28
[ "https://wordpress.stackexchange.com/questions/108099", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1555/" ]
I am using the SimpleReach plugin that adds some content to every post using the content hook. The content that is being added is ``` <!-- SimpleReach Slide Plugin Version: {{srslide_plugin_version}} --> <script type='text/javascript' id='simplereach-slide-tag'> __reach_config = { pid: '{{srslide_pid}}', ...
A couple of *caveats* before beginning. It tried to run that plugin but apparently I have to register with a third party site before I can use it, so that throws a wrench in testing. Second, I am having trouble duplicating this problem. That may be because I have beaten my dev stack up too much and it is time to wipe ...
108,122
<p>I am battling with the following:</p> <pre><code> $themeId = ""; $pathname = get_site_url(); if($pathname == 'domain2.com'){ $themeId = "gold";} else{ $themeId = "blue";} wp_register_style('theme-skin',THEMEURI . '/css/'.get_option($themeId).'-style.css', 3 , false, 'all'); </...
[ { "answer_id": 108124, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 0, "selected": false, "text": "<p>If you refer to <a href=\"http://codex.wordpress.org/Function_Reference/get_site_url\" rel=\"nofollow\">the Codex ...
2013/07/28
[ "https://wordpress.stackexchange.com/questions/108122", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27604/" ]
I am battling with the following: ``` $themeId = ""; $pathname = get_site_url(); if($pathname == 'domain2.com'){ $themeId = "gold";} else{ $themeId = "blue";} wp_register_style('theme-skin',THEMEURI . '/css/'.get_option($themeId).'-style.css', 3 , false, 'all'); ``` So basical...
The Misconception ----------------- [`get_site_url()`](http://codex.wordpress.org/Function_Reference/get_site_url) retrieves the `site_url` option *from the database*, as set under *General Settings* in the administrative backend / wp-admin. *If* this is indeed > > the exact same wordpress installation > > > it...
108,132
<p>Is this possible? I want to let it check all my posts to see if there is a embedded Youtube video. If so, I want to show that on a different page, embedded and linking to that particular post...</p> <p>I tried the following snippet, but that did not work for me. It doesn't embed a video...</p> <pre><code>function ...
[ { "answer_id": 108134, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": false, "text": "<p>Without even running that code I can see a pretty significant problem. You describe the goal as to \"check a...
2013/07/28
[ "https://wordpress.stackexchange.com/questions/108132", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34977/" ]
Is this possible? I want to let it check all my posts to see if there is a embedded Youtube video. If so, I want to show that on a different page, embedded and linking to that particular post... I tried the following snippet, but that did not work for me. It doesn't embed a video... ``` function aihato_latest_video()...
Without even running that code I can see a pretty significant problem. You describe the goal as to "check all my posts to see if there is a embedded YouTube video" but the query is restricted to only one post. And then, you are only attempting to use the very first post in the results (if the query works at all) anyw...
108,152
<p>When we do a search in wordpress the url appears like this:</p> <pre><code>http://example.com?s=hello </code></pre> <p>But I am using s= query variable for another purpose. so I wish to change default wordpress s= to search=.</p> <p>The updated code should not work of s= for wordpress search, instead it should on...
[ { "answer_id": 108153, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 3, "selected": true, "text": "<p>The code you found works not by changing the query variable but by converting another variable into the <code...
2013/07/29
[ "https://wordpress.stackexchange.com/questions/108152", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11628/" ]
When we do a search in wordpress the url appears like this: ``` http://example.com?s=hello ``` But I am using s= query variable for another purpose. so I wish to change default wordpress s= to search=. The updated code should not work of s= for wordpress search, instead it should only support search=. I tried a co...
The code you found works not by changing the query variable but by converting another variable into the `s` variable that WordPress expects. If you look at the [`WP_Query` object](http://core.trac.wordpress.org/browser/tags/3.5.2/wp-includes/query.php), that `s` parameter is pretty deeply embedded into Core functiona...
108,155
<p>I'm trying to create a sidebar where there are two inputs side by side: Search|Subscribe. When the user clicks on one input (Search, for example), I want the second (Subscribe) to disappear so the other input can grow to fill the space. My guess is that this is not possible with pure CSS, so will it require jQuery? ...
[ { "answer_id": 108153, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 3, "selected": true, "text": "<p>The code you found works not by changing the query variable but by converting another variable into the <code...
2013/07/29
[ "https://wordpress.stackexchange.com/questions/108155", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4132/" ]
I'm trying to create a sidebar where there are two inputs side by side: Search|Subscribe. When the user clicks on one input (Search, for example), I want the second (Subscribe) to disappear so the other input can grow to fill the space. My guess is that this is not possible with pure CSS, so will it require jQuery? If ...
The code you found works not by changing the query variable but by converting another variable into the `s` variable that WordPress expects. If you look at the [`WP_Query` object](http://core.trac.wordpress.org/browser/tags/3.5.2/wp-includes/query.php), that `s` parameter is pretty deeply embedded into Core functiona...
108,175
<p><em>(I'm using <code>Wordpress HTTPS</code> plugin to force <code>Admin</code> mode to run under <code>HTTPS</code>.<br />Its fine for Admin Panel.)</em></p> <p>But still, once i'm under <code>HTTPS</code> mode, every front pages are broken because of, it is saying some front-pages <code>Asset Files</code> <strong>...
[ { "answer_id": 108212, "author": "montrealist", "author_id": 8105, "author_profile": "https://wordpress.stackexchange.com/users/8105", "pm_score": 2, "selected": false, "text": "<p>Here's what I did to set up SSL for one of the clients.</p>\n\n<p>1: Put this into <code>wp-config.php</cod...
2013/07/29
[ "https://wordpress.stackexchange.com/questions/108175", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35907/" ]
*(I'm using `Wordpress HTTPS` plugin to force `Admin` mode to run under `HTTPS`. Its fine for Admin Panel.)* But still, once i'm under `HTTPS` mode, every front pages are broken because of, it is saying some front-pages `Asset Files` **are coming as normal `HTTP`** (without 'S') which are then getting blocked to loa...
Here's what I did to set up SSL for one of the clients. 1: Put this into `wp-config.php` in order to enable SSL on the admin side. ``` define('FORCE_SSL_ADMIN', true); define('FORCE_SSL_LOGIN', true); ``` 2: Make sure in `Settings -> General` the URL in both fields is preceeded by `https://` 3: Put this snippet (m...
108,185
<p>How to have pagination of RSS2 feed ?</p> <p>My current RSS link is similar to :</p> <pre><code>http://www.example.com/?feed=rss2 </code></pre> <p>I tried: </p> <pre><code>http://www.example.com/?feed=rss2&amp;page=2 </code></pre> <p>But WordPress still returns me with same set of result, given that I set 10 po...
[ { "answer_id": 108186, "author": "Mark Davidson", "author_id": 34111, "author_profile": "https://wordpress.stackexchange.com/users/34111", "pm_score": 5, "selected": true, "text": "<p>You want to use <code>paged</code> not <code>page</code> in the request and it should work.</p>\n\n<p>Yo...
2013/07/29
[ "https://wordpress.stackexchange.com/questions/108185", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3608/" ]
How to have pagination of RSS2 feed ? My current RSS link is similar to : ``` http://www.example.com/?feed=rss2 ``` I tried: ``` http://www.example.com/?feed=rss2&page=2 ``` But WordPress still returns me with same set of result, given that I set 10 posts per page in > > Dashboard > Settings > Reading > Synd...
You want to use `paged` not `page` in the request and it should work. You can find more information about WordPress pagination paged parameter [here](https://codex.wordpress.org/Pagination#Adding_the_.22paged.22_parameter_to_a_query).
108,206
<p>I'm storing posts, a user follows in a custom table that has the columns <code>id</code>, <code>post_id</code> and <code>user_id</code>. To fetch posts that a user follows I have extended the WP_Query as follows:</p> <pre><code>class WP_Query_Posts_User_Follows extends WP_Query { function __construct($args=arra...
[ { "answer_id": 134023, "author": "adrian7", "author_id": 7171, "author_profile": "https://wordpress.stackexchange.com/users/7171", "pm_score": 0, "selected": false, "text": "<p>Here's an idea, however it will require the ability to make custom SQL queries - with $wpdb.</p>\n\n<p>Since yo...
2013/07/29
[ "https://wordpress.stackexchange.com/questions/108206", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9094/" ]
I'm storing posts, a user follows in a custom table that has the columns `id`, `post_id` and `user_id`. To fetch posts that a user follows I have extended the WP\_Query as follows: ``` class WP_Query_Posts_User_Follows extends WP_Query { function __construct($args=array()) { if ( !empty($args['followed_by'...
Here's an idea, however it will require the ability to make custom SQL queries - with $wpdb. Since you want to get posts followed by a user, you can create a view, with the following structure: ``` id user_id post_id post_title post_content ... (all other post fields) ``` don't worry about duplicating posts. When ...
108,215
<p>I have created a nice homepage where the posts are organized into two columns. Only somehow, in creating this, I must have erased the actual code that tells the posts to link to the corresponding post. So right now, the posts are all showing up on the homepage, but there is no way to go to the post - the post previe...
[ { "answer_id": 108218, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 1, "selected": false, "text": "<p>I don't know that this is 100% answerable without seeing your code, but in TwentyTwelve the links, <a href=\...
2013/07/29
[ "https://wordpress.stackexchange.com/questions/108215", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35310/" ]
I have created a nice homepage where the posts are organized into two columns. Only somehow, in creating this, I must have erased the actual code that tells the posts to link to the corresponding post. So right now, the posts are all showing up on the homepage, but there is no way to go to the post - the post previews ...
If you want that the featured image is clickable replace: ``` <?php the_post_thumbnail(); ?> ``` with ``` <a href="<?php the_permalink(); ?>" rel="bookmark"><?php <?php the_post_thumbnail(); ?></a> ``` For the title and date replace this: ``` <h1 class="entry-title"><?php the_title(); ?><br><small class="time"><...
108,219
<p>The default taxonomy, category. By default, only those with the <code>edit_posts</code> capability can assign categories during post creation/editing.</p> <p>I have a role with very limited capabilities. I want to let users in this role be able to assign categories during custom-post-type creation/editing, but I ca...
[ { "answer_id": 108250, "author": "gmazzap", "author_id": 35541, "author_profile": "https://wordpress.stackexchange.com/users/35541", "pm_score": 3, "selected": true, "text": "<p>This should works</p>\n\n<pre><code>add_action( 'init', 'register_category_again', 1 );\n\nfunction register_c...
2013/07/29
[ "https://wordpress.stackexchange.com/questions/108219", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35920/" ]
The default taxonomy, category. By default, only those with the `edit_posts` capability can assign categories during post creation/editing. I have a role with very limited capabilities. I want to let users in this role be able to assign categories during custom-post-type creation/editing, but I cannot give them the `e...
This should works ``` add_action( 'init', 'register_category_again', 1 ); function register_category_again() { $user = wp_get_current_user(); if ( $user->roles[0] != 'your_custom_role' ) return; global $wp_taxonomies; unset( $wp_taxonomies['category'] ); global $wp_rewrite; $rewrite = array( 'hierarch...
108,221
<p>I have a mobile version I'm building outside of Wordpress in a subfolder on the same server as my Wordpress install. I'm including the wp-load.php file to pull content from the WordPress database.</p> <p>If I turn this plugin on (<a href="http://wordpress.org/plugins/php-mobile-redirect/" rel="nofollow">http://word...
[ { "answer_id": 108223, "author": "Mark Davidson", "author_id": 34111, "author_profile": "https://wordpress.stackexchange.com/users/34111", "pm_score": 0, "selected": false, "text": "<p>I haven't tested this but in the <code>index.php</code> for your mobile site can you add </p>\n\n<p><co...
2013/07/29
[ "https://wordpress.stackexchange.com/questions/108221", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35921/" ]
I have a mobile version I'm building outside of Wordpress in a subfolder on the same server as my Wordpress install. I'm including the wp-load.php file to pull content from the WordPress database. If I turn this plugin on (<http://wordpress.org/plugins/php-mobile-redirect/>), it goes into an endless loop. I realize n...
Disable the plugin at all and in your `function.php` add ``` add_action('init', 'my_mobile_redirect'); function get_first_url_subdir() { return str_replace( str_replace( array('http://', 'https://'), '', get_site_url() ), '', $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']); } function redirect_mobile_with_cook...
108,225
<p>I can´t get works fine the pagination in archives for wordpress when i want limite the posts by page , if i let pagination by default as 10 from backend i haven´t problems but if i use this no works </p> <pre><code>$wp_query-&gt;posts_per_page = 5; if ( have_posts() ) : while ( have_posts() ) : the_post(); </code><...
[ { "answer_id": 108229, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": false, "text": "<p>You should not be setting the <code>posts_per_page</code> value in the template, nor should you be setting t...
2013/07/29
[ "https://wordpress.stackexchange.com/questions/108225", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32760/" ]
I can´t get works fine the pagination in archives for wordpress when i want limite the posts by page , if i let pagination by default as 10 from backend i haven´t problems but if i use this no works ``` $wp_query->posts_per_page = 5; if ( have_posts() ) : while ( have_posts() ) : the_post(); ``` For example in othe...
You should not be setting the `posts_per_page` value in the template, nor should you be setting the object property directly after the query has run. That is going to cause the object data to become out of sync with itself. You need to alter that value with a filter on `pre_get_posts`. ``` function pregp_archive_ppp...
108,236
<p>I want to edit my gallery's css file. Where do I find it? or Am I override it? PS: I've got 5 different gallery in 5 different page..</p>
[ { "answer_id": 108229, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": false, "text": "<p>You should not be setting the <code>posts_per_page</code> value in the template, nor should you be setting t...
2013/07/29
[ "https://wordpress.stackexchange.com/questions/108236", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35889/" ]
I want to edit my gallery's css file. Where do I find it? or Am I override it? PS: I've got 5 different gallery in 5 different page..
You should not be setting the `posts_per_page` value in the template, nor should you be setting the object property directly after the query has run. That is going to cause the object data to become out of sync with itself. You need to alter that value with a filter on `pre_get_posts`. ``` function pregp_archive_ppp...