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
143,574
<p>While on any given link that has a CSS Classes value, I'd like to do something like this:</p> <pre><code>$css_classes = get_current_menu_item_css_classes(); if ( $css_classes == 'mycustomclass' ) : // do something </code></pre> <p>Thanks</p> <p><img src="https://i.stack.imgur.com/D45LE.png" alt="enter image d...
[ { "answer_id": 143554, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": false, "text": "<p>As soon as you hit \"Add New\" and the new post pages starts to load, WordPress inserts a mostly blank post ...
2014/05/06
[ "https://wordpress.stackexchange.com/questions/143574", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38286/" ]
While on any given link that has a CSS Classes value, I'd like to do something like this: ``` $css_classes = get_current_menu_item_css_classes(); if ( $css_classes == 'mycustomclass' ) : // do something ``` Thanks ![enter image description here](https://i.stack.imgur.com/D45LE.png)
For whatever reason `get_post_meta()` wasn't working when run inside the `wp_insert_post_data()` filter. However, after doing a `var_dump( $postarr )` I saw that the meta keys were being populated with the expected values. I simply replaced the `get_post_meta()` function lines w/ the following: ``` $a = isset( $posta...
143,582
<p>I couldn't find the right way to get the list of all products for a given category ID (not category name).</p> <p>The code I am using to get the categories list is the following, it works fine:</p> <pre><code>$args = array( 'orderby' =&gt; $orderby, 'order' =&gt; $order, 'h...
[ { "answer_id": 147270, "author": "benz001", "author_id": 11864, "author_profile": "https://wordpress.stackexchange.com/users/11864", "pm_score": 5, "selected": false, "text": "<p>I suspect the main problem is that you should be using the <code>WP_Query</code> object rather than <code>get...
2014/05/06
[ "https://wordpress.stackexchange.com/questions/143582", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13324/" ]
I couldn't find the right way to get the list of all products for a given category ID (not category name). The code I am using to get the categories list is the following, it works fine: ``` $args = array( 'orderby' => $orderby, 'order' => $order, 'hide_empty' => 0, ...
I suspect the main problem is that you should be using the `WP_Query` object rather than `get_posts()`. The later by default only returns items with a post\_type of `post` not products, So given a category with ID 26, the following code would return it's products (WooCommerce 3+): ``` $args = array( 'post_typ...
143,594
<p>How would I go about checking if current user registered more than, say, 30 days ago? I would like to display certain content only to that group of users.</p> <p>Thanks very much in advance for your help.</p>
[ { "answer_id": 143596, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<p>First you need to somehow get the User you need (form? admin? foo? bar? baz?)</p>\n\n<pre><code># Get Registration...
2014/05/07
[ "https://wordpress.stackexchange.com/questions/143594", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1826/" ]
How would I go about checking if current user registered more than, say, 30 days ago? I would like to display certain content only to that group of users. Thanks very much in advance for your help.
You can try this: ``` /** * Is the current user registred for more than x days ago? * * Based on the compare idea in this answer: * http://stackoverflow.com/a/7130744/2078474 * * @link http://wordpress.stackexchange.com/a/143597/26350 * @param int $reg_days_ago * @return bool */ function is_user_reg_ma...
143,600
<p>I'm hoping someone can steer me in the right direction. I have a custom post type called 'locations'. I have another custom post type called 'testimonials'. </p> <p>What I'd really like to do is be able to associate a 'testimonial' with a 'location'. So I was trying to figure out if I could some how list those loca...
[ { "answer_id": 143596, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<p>First you need to somehow get the User you need (form? admin? foo? bar? baz?)</p>\n\n<pre><code># Get Registration...
2014/05/07
[ "https://wordpress.stackexchange.com/questions/143600", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/44899/" ]
I'm hoping someone can steer me in the right direction. I have a custom post type called 'locations'. I have another custom post type called 'testimonials'. What I'd really like to do is be able to associate a 'testimonial' with a 'location'. So I was trying to figure out if I could some how list those locations with...
You can try this: ``` /** * Is the current user registred for more than x days ago? * * Based on the compare idea in this answer: * http://stackoverflow.com/a/7130744/2078474 * * @link http://wordpress.stackexchange.com/a/143597/26350 * @param int $reg_days_ago * @return bool */ function is_user_reg_ma...
143,616
<p>I need to add a conditional menu item such as "/at" or "/de" or "/ch" in the <code>wp_nav_menu</code>. Since the link is conditional (based on the country the website is being viewed), it can't be added from the backend but instead has to be hardcoded. </p> <p>How do I add this new conditional link at the end of wh...
[ { "answer_id": 143751, "author": "Tom", "author_id": 51330, "author_profile": "https://wordpress.stackexchange.com/users/51330", "pm_score": 3, "selected": true, "text": "<p>This is what worked for me (based on <a href=\"http://www.wpbeginner.com/wp-themes/how-to-add-custom-items-to-spec...
2014/05/07
[ "https://wordpress.stackexchange.com/questions/143616", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51330/" ]
I need to add a conditional menu item such as "/at" or "/de" or "/ch" in the `wp_nav_menu`. Since the link is conditional (based on the country the website is being viewed), it can't be added from the backend but instead has to be hardcoded. How do I add this new conditional link at the end of what the `wp_nav_menu` ...
This is what worked for me (based on [this](http://www.wpbeginner.com/wp-themes/how-to-add-custom-items-to-specific-wordpress-menus/)).. hope it will be helpful for others too.. ``` add_filter( 'wp_nav_menu_items','primary_navigation', 10, 2 ); function primary_navigation( $items, $args ) { if( $args->theme_locati...
143,622
<p>First things first:</p> <p>I've spent most of today going over these forums; the stackoverflow forums; the php.net manual; and a bunch of random sites I found through Google Search - so, if I've missed the answer and it seems like I'm asking an already answered question I'm sorry. I've probably just been looking at...
[ { "answer_id": 143751, "author": "Tom", "author_id": 51330, "author_profile": "https://wordpress.stackexchange.com/users/51330", "pm_score": 3, "selected": true, "text": "<p>This is what worked for me (based on <a href=\"http://www.wpbeginner.com/wp-themes/how-to-add-custom-items-to-spec...
2014/05/07
[ "https://wordpress.stackexchange.com/questions/143622", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51266/" ]
First things first: I've spent most of today going over these forums; the stackoverflow forums; the php.net manual; and a bunch of random sites I found through Google Search - so, if I've missed the answer and it seems like I'm asking an already answered question I'm sorry. I've probably just been looking at the same ...
This is what worked for me (based on [this](http://www.wpbeginner.com/wp-themes/how-to-add-custom-items-to-specific-wordpress-menus/)).. hope it will be helpful for others too.. ``` add_filter( 'wp_nav_menu_items','primary_navigation', 10, 2 ); function primary_navigation( $items, $args ) { if( $args->theme_locati...
143,628
<p>In cases i want to add individual styles for an element its easy i just add inline styles inside p tags, because _wp_add_global_attributes has style attribute....</p> <p>but when i want to add tag itslef to target/select multiple elements TinyMCE editor removes it entirely... so I got inside core and found filter ...
[ { "answer_id": 179671, "author": "cyberhobo", "author_id": 41527, "author_profile": "https://wordpress.stackexchange.com/users/41527", "pm_score": 2, "selected": true, "text": "<p>There are some things to try in this <a href=\"https://stackoverflow.com/questions/23297466/how-to-prevent-w...
2014/05/07
[ "https://wordpress.stackexchange.com/questions/143628", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/36203/" ]
In cases i want to add individual styles for an element its easy i just add inline styles inside p tags, because \_wp\_add\_global\_attributes has style attribute.... but when i want to add tag itslef to target/select multiple elements TinyMCE editor removes it entirely... so I got inside core and found filter tiny\_m...
There are some things to try in this [stackoverflow thread](https://stackoverflow.com/questions/23297466/how-to-prevent-wordpress-3-9-tinymce-4-from-stripping-style-tags). The one I'm trying: ``` add_filter('tiny_mce_before_init', 'vsl2014_filter_tiny_mce_before_init'); function vsl2014_filter_tiny_mce_before_init( $o...
143,649
<p>Basically I've applied this way to show certain colors on pages like search.php or a list on home. What it does is it reads a variable that gets a field from WP, if that field is equal to a certain number then it adds a class name which in CSS has a color Now the field on a single page is there, though whenever I ad...
[ { "answer_id": 143659, "author": "codearachnid", "author_id": 28798, "author_profile": "https://wordpress.stackexchange.com/users/28798", "pm_score": 0, "selected": false, "text": "<p>Since you are specifying the class based off a value set elsewhere it seems you may have set this variab...
2014/05/07
[ "https://wordpress.stackexchange.com/questions/143649", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48416/" ]
Basically I've applied this way to show certain colors on pages like search.php or a list on home. What it does is it reads a variable that gets a field from WP, if that field is equal to a certain number then it adds a class name which in CSS has a color Now the field on a single page is there, though whenever I add t...
Actually you just need a callback for the `body_class` filter. Then simply check what correlation you got between your meta data and the actual value: If it is a 1:1 correlation, you can just add the result of `get_field()` as new body class. Example: `array( get_field( 'mem_id' ) )` if the `mem_id` meta value would be...
143,650
<p>I would like to embed videos &amp; images by entering url in my wordpress site. In WordPress repsitory there are many plugins for embed video by url but in my site I want to enable this functionality from frontend. Registered users can be able to enter a url and this video will enbed in the post. How can I achieve ...
[ { "answer_id": 143653, "author": "totels", "author_id": 23446, "author_profile": "https://wordpress.stackexchange.com/users/23446", "pm_score": -1, "selected": false, "text": "<p>I haven't used any of the frontend submission plugins, but there are a decent handful of them around. WPMU re...
2014/05/07
[ "https://wordpress.stackexchange.com/questions/143650", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/44924/" ]
I would like to embed videos & images by entering url in my wordpress site. In WordPress repsitory there are many plugins for embed video by url but in my site I want to enable this functionality from frontend. Registered users can be able to enter a url and this video will enbed in the post. How can I achieve this.
Wordpress supports quite a few [embeds](https://codex.wordpress.org/Embeds) including YouTube since [WordPress 2.9](https://codex.wordpress.org/Version_2.9). To render anywhere, just pass your content through [`the_content`](https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content) filter and it should auto...
143,654
<p>I am reading wp codex about outputing custom field value.</p> <p><a href="http://codex.wordpress.org/Function_Reference/get_post_custom" rel="nofollow">http://codex.wordpress.org/Function_Reference/get_post_custom</a></p> <p>From that link, It shows how to output all custom fields associated with specific post</p>...
[ { "answer_id": 143656, "author": "codearachnid", "author_id": 28798, "author_profile": "https://wordpress.stackexchange.com/users/28798", "pm_score": 1, "selected": false, "text": "<p>You are on the right track, but digging a little deeper into the codex you'll find methods for <a href=\...
2014/05/07
[ "https://wordpress.stackexchange.com/questions/143654", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/46060/" ]
I am reading wp codex about outputing custom field value. <http://codex.wordpress.org/Function_Reference/get_post_custom> From that link, It shows how to output all custom fields associated with specific post How can I take only specific custom fields value? For example I added custom field name "SkypeID". In each ...
I would suggest you could try something like this to insert the Skype id by using [get\_post\_meta](http://codex.wordpress.org/Function_Reference/get_post_meta): ``` if (get_post_meta($post->ID, 'Skype_ID', true) == true) { echo get_post_meta( $post_id, "Skype_ID", true ); } ```
143,661
<p>I want to remove pagination by changing the default screen option value for <strong>posts per page</strong>, <strong>pages per page</strong> and <strong>media items per page</strong>, in the admin area, to <code>999</code>. The default value is set to <code>20</code>. I found the answer I need (I have pasted below f...
[ { "answer_id": 143678, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 1, "selected": true, "text": "<p>You need <code>upload_per_page</code>:</p>\n\n<pre><code>add_filter( 'get_user_option_edit_upload_per_page'...
2014/05/07
[ "https://wordpress.stackexchange.com/questions/143661", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40679/" ]
I want to remove pagination by changing the default screen option value for **posts per page**, **pages per page** and **media items per page**, in the admin area, to `999`. The default value is set to `20`. I found the answer I need (I have pasted below from @KrzysiekDróżdż's answer in this question: [Change default s...
You need `upload_per_page`: ``` add_filter( 'get_user_option_edit_upload_per_page', 'my_edit_per_page', 10, 3 ); ```
143,669
<p>I want to exclude a certain tag from my home page not a category only post that hold the tag for example "olive";</p> <p>I found a function for that which is like this </p> <pre><code> function exclude_tag($query) { if ( $query-&gt;is_home) { $query-&gt; set('tag__not_in',array(x)); } return $query; } a...
[ { "answer_id": 143672, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": false, "text": "<ol>\n<li>Go to the backend to Posts -> Tags, click a tag to edit, then look\nat the URL and you should see <co...
2014/05/07
[ "https://wordpress.stackexchange.com/questions/143669", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50830/" ]
I want to exclude a certain tag from my home page not a category only post that hold the tag for example "olive"; I found a function for that which is like this ``` function exclude_tag($query) { if ( $query->is_home) { $query-> set('tag__not_in',array(x)); } return $query; } add_filter('pre_get_posts','...
In your admin, go to Posts > Tags and then click edit for the tag you're after - the URL in your browser address bar will look like: ``` http://example.com/wp-admin/edit-tags.php?action=edit&taxonomy=post_tag&tag_ID=X&post_type=post ``` See the part where `tag_ID=X` - that X is your tag ID.
143,680
<p>Is there any possible way to sort a new Wordpress post query by the title, but numerically instead of alphabetically?</p> <p>I have some titles that have a lot of the same name alphabetically, then have a number afterwards, so of course for example Wordpress is putting <code>title12</code> ahead of <code>title1</co...
[ { "answer_id": 143682, "author": "woony", "author_id": 17541, "author_profile": "https://wordpress.stackexchange.com/users/17541", "pm_score": 2, "selected": false, "text": "<p>Well, technically what WP is doing is correct. \nYou can either rename your titles using prefixed 0's. </p>\n\n...
2014/05/07
[ "https://wordpress.stackexchange.com/questions/143680", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33438/" ]
Is there any possible way to sort a new Wordpress post query by the title, but numerically instead of alphabetically? I have some titles that have a lot of the same name alphabetically, then have a number afterwards, so of course for example Wordpress is putting `title12` ahead of `title1`. ``` $args = array( 'orderb...
Well, technically what WP is doing is correct. You can either rename your titles using prefixed 0's. ``` Title 001 Title 012 ``` Otherwise You can use sorting using the publish date Or you can use an order meta field and sort on that one using `wp_query`
143,710
<p>I'm using <strong><a href="http://www.webhammer.co.uk/bespoke-wordpress-plugins/wp-custom-search" rel="nofollow noreferrer">WP Custom Search</a></strong> plugin to generate Advanced Search in one of my newly developed WP site. Though the plugin is not completely bug-free, but it's working just fine (excepts some Und...
[ { "answer_id": 143949, "author": "Mayeenul Islam", "author_id": 22728, "author_profile": "https://wordpress.stackexchange.com/users/22728", "pm_score": 2, "selected": true, "text": "<p>As Milo stated, it seems it's a problem of the plugin. And solely for this project of mine, I'm not goi...
2014/05/07
[ "https://wordpress.stackexchange.com/questions/143710", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22728/" ]
I'm using **[WP Custom Search](http://www.webhammer.co.uk/bespoke-wordpress-plugins/wp-custom-search)** plugin to generate Advanced Search in one of my newly developed WP site. Though the plugin is not completely bug-free, but it's working just fine (excepts some Undefined Offset warnings, I'm ignoring them for its bet...
As Milo stated, it seems it's a problem of the plugin. And solely for this project of mine, I'm not going for such a big dig out, and I'm actually going for a fallback. **I repeat, it's not a solution, just a problem hiding measure.** I checked, as Laxmana said that, is there any menu items found there. If there're me...
143,715
<p>Been trying to chase down an error on this <a href="http://www.naswmaine.org/site/teams/committees/" rel="nofollow">page</a>:</p> <blockquote> <p>Catchable fatal error: Object of class WP_Error could not be converted to string</p> </blockquote> <p>I have a custom post type and taxonomy:</p> <p>Taxonomy: <code...
[ { "answer_id": 143716, "author": "Stephen S.", "author_id": 5019, "author_profile": "https://wordpress.stackexchange.com/users/5019", "pm_score": 0, "selected": false, "text": "<p>EDIT: I had suggested adding <code>endforeach;</code>, but I just relooked at the code example in the codex ...
2014/05/07
[ "https://wordpress.stackexchange.com/questions/143715", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51368/" ]
Been trying to chase down an error on this [page](http://www.naswmaine.org/site/teams/committees/): > > Catchable fatal error: Object of class WP\_Error could not be converted > to string > > > I have a custom post type and taxonomy: Taxonomy: `team_categories` * Term: "Committees" (among others) + Child ter...
Well, you `echo` an object. Never just echo stuff if you are *not* sure what you get in return. Take a look at the function: The error itself is quite clear: ``` function get_term_link( $term, $taxonomy = '') { global $wp_rewrite; if ( !is_object($term) ) { if ( is_int($term) ) { $term = g...
143,750
<p>I am developing my plugin and I am getting this error:</p> <p>The plugin generated 357954 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.</p> <p>Now my activation hook looks ...
[ { "answer_id": 143753, "author": "Peter", "author_id": 42857, "author_profile": "https://wordpress.stackexchange.com/users/42857", "pm_score": 0, "selected": false, "text": "<p>OK, sorry for this, but I wasn't reading codex properly.... Anyway for all of you who have same issue query rea...
2014/05/08
[ "https://wordpress.stackexchange.com/questions/143750", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/42857/" ]
I am developing my plugin and I am getting this error: The plugin generated 357954 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin. Now my activation hook looks like this: ``` ...
Its not that `$wpdb->query` does not need `$wpdb->prepare()`, it's because of not using `$wpdb->prepare()` in a correct manner. In your case `$wpdb->prepare()` never received any values which it must. Please refer to the [Codex](http://codex.wordpress.org/Class_Reference/wpdb#Protect_Queries_Against_SQL_Injection_Atta...
143,761
<p>I am trying to make a list of all my posts in a custom post type by the taxonomy term e.g.</p> <p>Term name 1 - post 1 - post 2 - post 3</p> <p>Term name 2 - post 1 - post 2 - post 3</p> <p>Term name 3 - post 1 - post 2 - post 3</p> <p>I have found the function which lists the terms (get_terms) but can'...
[ { "answer_id": 143912, "author": "Gareth Gillman", "author_id": 33936, "author_profile": "https://wordpress.stackexchange.com/users/33936", "pm_score": 2, "selected": true, "text": "<p>Sorted via <code>get_terms</code> and <code>WP_Query</code></p>\n\n<pre><code>&lt;?php\n $terms = get_...
2014/05/08
[ "https://wordpress.stackexchange.com/questions/143761", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33936/" ]
I am trying to make a list of all my posts in a custom post type by the taxonomy term e.g. Term name 1 - post 1 - post 2 - post 3 Term name 2 - post 1 - post 2 - post 3 Term name 3 - post 1 - post 2 - post 3 I have found the function which lists the terms (get\_terms) but can't work out a way to list the t...
Sorted via `get_terms` and `WP_Query` ``` <?php $terms = get_terms("county"); if ( !empty( $terms ) && !is_wp_error( $terms ) ){ foreach ( $terms as $term ) { $my_query = new WP_Query('post_type=venues&posts_per_page=-1&county='.$term->name); while ($my_query->have_posts()) : $my_query->the_post(); ...
143,777
<p>I'd like to add a custom post type "News" that has it's own Tags and Categories and I'd like to add the appropriate code to my functions.php file.</p> <p>I've tried plugins but I don't get tags and categories columns in the list of posts in the new post type.</p> <p>Thanks</p>
[ { "answer_id": 143778, "author": "TomC", "author_id": 36980, "author_profile": "https://wordpress.stackexchange.com/users/36980", "pm_score": 1, "selected": false, "text": "<p>When you define the Custom Post Type you decide if all those attributes are available or not, so I guess you're ...
2014/05/08
[ "https://wordpress.stackexchange.com/questions/143777", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40536/" ]
I'd like to add a custom post type "News" that has it's own Tags and Categories and I'd like to add the appropriate code to my functions.php file. I've tried plugins but I don't get tags and categories columns in the list of posts in the new post type. Thanks
Creating the Post Type ====================== `register_post_type` is your friend here. This is what plugins etc use to register the post type. For example here is a basic Books post type: ``` function codex_custom_init() { $args = array( 'public' => true, 'label' => 'Books' ); register_post...
143,789
<p>Is there a way to output the default value of a <code>wp_customize</code> text field type using the <code>echo get_theme_mod ();</code> without actually going in the Theme Customizer, modifying something and then saving it? </p> <p>I just read on another <a href="https://wordpress.stackexchange.com/questions/111257...
[ { "answer_id": 143815, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 4, "selected": true, "text": "<p>Sadly not - all your customize controls are hooked onto <code>customize_register</code>, so they'll only ev...
2014/05/08
[ "https://wordpress.stackexchange.com/questions/143789", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13214/" ]
Is there a way to output the default value of a `wp_customize` text field type using the `echo get_theme_mod ();` without actually going in the Theme Customizer, modifying something and then saving it? I just read on another [stackexchange question](https://wordpress.stackexchange.com/questions/111257/get-theme-mod-r...
Sadly not - all your customize controls are hooked onto `customize_register`, so they'll only ever come into play when customising the theme for the first time. [`get_theme_mod()`](http://codex.wordpress.org/Function_Reference/get_theme_mod) takes a second argument for a "default" value - yes, it means two instances o...
143,801
<p>I created a function in functions.php that adds some rewrite rules:</p> <pre><code>function add_rewrite_rules() { add_rewrite_rule('events/page/([0-9])*/?', 'index.php?pagename=events&amp;paged=$matches[1]', 'top'); [...] global $wp_rewrite; $wp_rewrite-&gt;flush_rules(); } </code></pre> <p>I w...
[ { "answer_id": 143806, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 0, "selected": false, "text": "<p>I wonder if this will work:</p>\n\n<pre><code>add_action( 'activated_plugin', function(){\n\n // your stuf...
2014/05/08
[ "https://wordpress.stackexchange.com/questions/143801", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50491/" ]
I created a function in functions.php that adds some rewrite rules: ``` function add_rewrite_rules() { add_rewrite_rule('events/page/([0-9])*/?', 'index.php?pagename=events&paged=$matches[1]', 'top'); [...] global $wp_rewrite; $wp_rewrite->flush_rules(); } ``` I would like to execute it every tim...
1. Add your rewrite rules on the `init` action hook. 2. In your personal activation function, both a) add the rewrite rules and b) flush the rewrite rules. One time. This is the only time you need to flush the rules. Alternatively, if your rewrite rules can change through user input, then you need to flush them when t...
143,812
<h2>What I am looking to do:</h2> <p>Setup <code>WP_Query</code> pagination in a single-custom-post-type.php template file</p> <h2>What I have done</h2> <p>1) Created a post type called "authors". Each post within that post type is an individual author.</p> <p>2) Standard edit post screen pages contain a dropdown w...
[ { "answer_id": 143825, "author": "Stephen S.", "author_id": 5019, "author_profile": "https://wordpress.stackexchange.com/users/5019", "pm_score": 0, "selected": false, "text": "<p>Based on another similar WPSE question \"<a href=\"https://wordpress.stackexchange.com/questions/57884/pagin...
2014/05/08
[ "https://wordpress.stackexchange.com/questions/143812", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49947/" ]
What I am looking to do: ------------------------ Setup `WP_Query` pagination in a single-custom-post-type.php template file What I have done ---------------- 1) Created a post type called "authors". Each post within that post type is an individual author. 2) Standard edit post screen pages contain a dropdown which...
You have 2 problems. First problem ------------- The line ``` $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; ``` will fail, because on singular post view, when the URL contains `'/page/XX/'`, the variable WordPress sets is `'page'` and not `'paged'`. You may think to use `'page'` instead of...
143,863
<p>I have two custom taxonomies called "custom-category" and "file_type". I am using the below code to list all the terms of "file_type" along with their associated posts. Like so:</p> <p>File_Type Term 1</p> <ul> <li>post</li> <li>post</li> <li>post</li> </ul> <p>File_Type Term 2</p> <ul> <li>post</li> <li>post</l...
[ { "answer_id": 143865, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 1, "selected": false, "text": "<p>Use a <code>tax_query</code> to set multiple taxonomy arguments. See <a href=\"http://codex.wordpress.org/Class_Re...
2014/05/09
[ "https://wordpress.stackexchange.com/questions/143863", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31345/" ]
I have two custom taxonomies called "custom-category" and "file\_type". I am using the below code to list all the terms of "file\_type" along with their associated posts. Like so: File\_Type Term 1 * post * post * post File\_Type Term 2 * post * post * post and so on... My problem is that I need to add another co...
You can directly add `'taxonomy_name'=>'term_slug'` in your current code. ``` $posts = get_posts(array( 'post_type' => 'product', 'file_type'=> $category->slug, 'custom-category' => 'learning-units' )); ``` For more reference check [WP\_Query Taxonomy Parameters](http://code...
143,893
<p>I wanted to create a loop which displays search results in <em>search.php</em> file.</p> <p>I followed all of the instructions in the WordPress Codex tutorial located in here:</p> <p><a href="https://codex.wordpress.org/The_Loop" rel="nofollow">https://codex.wordpress.org/The_Loop</a></p> <p>I have implemented th...
[ { "answer_id": 143910, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 0, "selected": false, "text": "<p>I very much doubt that <code>have_posts()</code> is the point of failure. That function is very simple, basi...
2014/05/09
[ "https://wordpress.stackexchange.com/questions/143893", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49230/" ]
I wanted to create a loop which displays search results in *search.php* file. I followed all of the instructions in the WordPress Codex tutorial located in here: <https://codex.wordpress.org/The_Loop> I have implemented the suggested code on my page like this: ``` <?php if ( have_posts() ) : while ( have_posts() ) ...
Your problem is the weird code at the top of the page. To understand what's happening let me state a standard loop in pseudocode: ``` if we still have posts to process while we still have posts to process mark this post as processed and move to the next one do things with it ( like printing the tit...
143,914
<p>I am creating a WP plugin, which shows information from an external database. The plugin will be distributed, the external database is on my own server.</p> <p>I know the following code will connect to my database:</p> <pre><code>$newdb = new wpdb($DB_USER, $DB_PASSWORD, $DB_NAME, $DB_HOST); $newdb-&gt;show_errors...
[ { "answer_id": 143931, "author": "MathSmath", "author_id": 1537, "author_profile": "https://wordpress.stackexchange.com/users/1537", "pm_score": 2, "selected": true, "text": "<p>I think that it's rare for a plugin to make a direct DB connection, for the very reason you're citing (among o...
2014/05/09
[ "https://wordpress.stackexchange.com/questions/143914", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51455/" ]
I am creating a WP plugin, which shows information from an external database. The plugin will be distributed, the external database is on my own server. I know the following code will connect to my database: ``` $newdb = new wpdb($DB_USER, $DB_PASSWORD, $DB_NAME, $DB_HOST); $newdb->show_errors(); ``` But I do not w...
I think that it's rare for a plugin to make a direct DB connection, for the very reason you're citing (among others, like port concerns, DB security best practices, etc.). In most cases, if you want your plugins to connect to an external data source, it's best to do it using an [API](http://en.wikipedia.org/wiki/Appli...
143,916
<p>Conditional php question... I have an array and need to add an OR boolean to check for an additional category 4. Don't know the syntax to use for adding more category id's. I've tried array('cat' => -9, -4, but that only recognizes first id. </p> <pre><code>query_posts( array_merge( $wp_query-&...
[ { "answer_id": 143919, "author": "тнє Sufi", "author_id": 28744, "author_profile": "https://wordpress.stackexchange.com/users/28744", "pm_score": 1, "selected": false, "text": "<p>You will need to put category IDs inside quote, like below:</p>\n\n<pre><code>'cat' =&gt; array ( -9, -4, -1...
2014/05/09
[ "https://wordpress.stackexchange.com/questions/143916", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/45462/" ]
Conditional php question... I have an array and need to add an OR boolean to check for an additional category 4. Don't know the syntax to use for adding more category id's. I've tried array('cat' => -9, -4, but that only recognizes first id. ``` query_posts( array_merge( $wp_query->query, ...
Your code fails because: ``` array( 'cat' => -9, -4 ); ``` is the same as: ``` array( 'cat' => -9, -4 ); ``` The -4 is its own element, not a part of the 'cat' argument. The correct way to do what you tried to do would be: ``` array ( 'cat' => array( -9, -4 ) ); ``` But this too would have fa...
143,950
<p>I'm writing a supplement plugin to <a href="http://wordpress.org/plugins/wordpress-mobile-pack/" rel="nofollow">Wordpress Mobile Pack</a> because I would like to use the default theme on pages that are assigned a certain page template. My plugin will only deal with the mobile switcher portion of that plugin, so the ...
[ { "answer_id": 143919, "author": "тнє Sufi", "author_id": 28744, "author_profile": "https://wordpress.stackexchange.com/users/28744", "pm_score": 1, "selected": false, "text": "<p>You will need to put category IDs inside quote, like below:</p>\n\n<pre><code>'cat' =&gt; array ( -9, -4, -1...
2014/05/09
[ "https://wordpress.stackexchange.com/questions/143950", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33911/" ]
I'm writing a supplement plugin to [Wordpress Mobile Pack](http://wordpress.org/plugins/wordpress-mobile-pack/) because I would like to use the default theme on pages that are assigned a certain page template. My plugin will only deal with the mobile switcher portion of that plugin, so the other components can be ignor...
Your code fails because: ``` array( 'cat' => -9, -4 ); ``` is the same as: ``` array( 'cat' => -9, -4 ); ``` The -4 is its own element, not a part of the 'cat' argument. The correct way to do what you tried to do would be: ``` array ( 'cat' => array( -9, -4 ) ); ``` But this too would have fa...
143,989
<p>I'm running a function that hooks into wp_trash_post and that should delete a custom taxonomy term that is the match of a custom post.</p> <p>The term description equals the ID of the custom post.</p> <pre> <code> function trash_custom_terms($post_id) { if ( 'custom_post' != get_post_type($post_id)) { retur...
[ { "answer_id": 143996, "author": "Jared Cobb", "author_id": 6737, "author_profile": "https://wordpress.stackexchange.com/users/6737", "pm_score": 1, "selected": false, "text": "<p>I'm not sure why you're seeing the ID increment, however one problem is that your function call to <code>get...
2014/05/10
[ "https://wordpress.stackexchange.com/questions/143989", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12027/" ]
I'm running a function that hooks into wp\_trash\_post and that should delete a custom taxonomy term that is the match of a custom post. The term description equals the ID of the custom post. ``` function trash_custom_terms($post_id) { if ( 'custom_post' != get_post_type($post_id)) { return; } $this_post_ID...
After inspected my code and the logs I could see that the problem was with the function I used to create a new taxonomy term when a new custom post was added. The code would only check for get\_post\_status = 'auto-draft' and would still run and recreate the term when get\_post\_status = 'trash' ``` function update...
143,994
<p>through the codex I read about how to use the post_class() function to create a css hook for styling the content.</p> <p>Here is the code I have, PHP:</p> <pre><code>&lt;li class="&lt;?php post_class();?&gt;"&gt; &lt;?php the_title(); ?&gt; &lt;/li&gt; &lt;p class="&lt;?php post_class(); ?&gt;"&gt; &lt;?php the_co...
[ { "answer_id": 143997, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 0, "selected": false, "text": "<p>This is wrong:</p>\n\n<pre><code>&lt;li class=\"&lt;?php post_class;?&gt;\"&gt; &lt;?php the_title(); ?&gt; ...
2014/05/10
[ "https://wordpress.stackexchange.com/questions/143994", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104926/" ]
through the codex I read about how to use the post\_class() function to create a css hook for styling the content. Here is the code I have, PHP: ``` <li class="<?php post_class();?>"> <?php the_title(); ?> </li> <p class="<?php post_class(); ?>"> <?php the_content(); ?> </p> ``` However, the following CSS does not ...
First of all, `<?php post_class(); ?>` function prints a string that contains html `'class'` attribute. So, whenever you are using this function inside class attribute, then you are actually printing another class attribute inside class attribute. That's why your class is not working. Secondly, since `<?php the_conten...
144,004
<p>The WP Customizer's <code>WP_Customize_Image_Control</code> returns the attachment's URL, but I need the ID because I want to output the image like this:</p> <pre><code>echo wp_get_attachment_image( $user_logo_id, 'riiskit-user-logo' ); </code></pre> <p>The reason for this is because I want the logo to be compatib...
[ { "answer_id": 174377, "author": "RichieAHB", "author_id": 45290, "author_profile": "https://wordpress.stackexchange.com/users/45290", "pm_score": 2, "selected": false, "text": "<p>I know this is old but I was looking for an answer to this problem so that I could save a thumbnail rather ...
2014/05/10
[ "https://wordpress.stackexchange.com/questions/144004", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51492/" ]
The WP Customizer's `WP_Customize_Image_Control` returns the attachment's URL, but I need the ID because I want to output the image like this: ``` echo wp_get_attachment_image( $user_logo_id, 'riiskit-user-logo' ); ``` The reason for this is because I want the logo to be compatible with the WP Retina 2x plugin. That...
This is very old, but for someone coming here via search `WP_Customize_Media_Control` control in WP since 4.2 give you the attachment id. Ref: <https://make.wordpress.org/core/2015/07/16/new-customizer-media-controls-in-4-3-and-4-2/>
144,005
<p>I have two identical copies of the same site on two different webhosting companies (besides the actual domain of course). One of them works all the time with pretty permalinks and the other works fine a day or so, but then all of a sudden it does not work and the permalink gives a 404 file not found, but only when v...
[ { "answer_id": 174377, "author": "RichieAHB", "author_id": 45290, "author_profile": "https://wordpress.stackexchange.com/users/45290", "pm_score": 2, "selected": false, "text": "<p>I know this is old but I was looking for an answer to this problem so that I could save a thumbnail rather ...
2014/05/10
[ "https://wordpress.stackexchange.com/questions/144005", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38848/" ]
I have two identical copies of the same site on two different webhosting companies (besides the actual domain of course). One of them works all the time with pretty permalinks and the other works fine a day or so, but then all of a sudden it does not work and the permalink gives a 404 file not found, but only when view...
This is very old, but for someone coming here via search `WP_Customize_Media_Control` control in WP since 4.2 give you the attachment id. Ref: <https://make.wordpress.org/core/2015/07/16/new-customizer-media-controls-in-4-3-and-4-2/>
144,037
<p>I'm playing around with a test site and I've set up a static page as home page.</p> <p>Now I want to make a menu item called <code>Blog</code> - with url <code>example.com/blog/</code> - where I'll list the latest articles. I made a custom page template and changed the <code>WP_Query</code> so that it queries a lis...
[ { "answer_id": 144039, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 2, "selected": true, "text": "<p>When you set up a static page as home page, you can set up also a page for the blog archive. If you do that, y...
2014/05/11
[ "https://wordpress.stackexchange.com/questions/144037", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17305/" ]
I'm playing around with a test site and I've set up a static page as home page. Now I want to make a menu item called `Blog` - with url `example.com/blog/` - where I'll list the latest articles. I made a custom page template and changed the `WP_Query` so that it queries a list of 10 latest posts. I then created a page...
When you set up a static page as home page, you can set up also a page for the blog archive. If you do that, you don't need to alter the WP\_Query in the blog page template, you only need to work with The loop like in a archive template file. When the page for the blog archive is requested, Wordpress will make the corr...
144,041
<p>I have custom fields in my custom post type. They should serve as a title and post slug for URL. Basically, whenever I change the content of the custom fields, the title field should react accordingly. E.g. if the field NAME contains 'John' and the SURNAME 'Smith', the title should transform to 'John Smith'. </p> ...
[ { "answer_id": 144119, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 1, "selected": false, "text": "<p>I think a good way to do what you want is hook the <a href=\"http://codex.wordpress.org/Plugin_API/Filter_Ref...
2014/05/11
[ "https://wordpress.stackexchange.com/questions/144041", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51510/" ]
I have custom fields in my custom post type. They should serve as a title and post slug for URL. Basically, whenever I change the content of the custom fields, the title field should react accordingly. E.g. if the field NAME contains 'John' and the SURNAME 'Smith', the title should transform to 'John Smith'. The user...
I think a good way to do what you want is hook the [`wp_insert_post_data`](http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_insert_post_data) filter. Here you can change the title and slug of the post before it is saved to database: ``` add_filter( 'wp_insert_post_data', 'wpse_update_post_title_and_slug' ); f...
144,044
<p>I have one multi-authored blog site and a few editors.</p> <p>What I want is to display the name of the editor along with the author's name in a post, so that it would read like: Posted by , Edited by </p> <p>Is it possible?</p>
[ { "answer_id": 144047, "author": "pascalvgemert", "author_id": 25063, "author_profile": "https://wordpress.stackexchange.com/users/25063", "pm_score": 2, "selected": false, "text": "<p>Try <code>the_modified_author()</code> or <code>get_the_modified_author()</code>, this should give you ...
2014/05/11
[ "https://wordpress.stackexchange.com/questions/144044", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41500/" ]
I have one multi-authored blog site and a few editors. What I want is to display the name of the editor along with the author's name in a post, so that it would read like: Posted by , Edited by Is it possible?
Here's a small screenshot of what this code produces: ![enter image description here](https://i.stack.imgur.com/QTk4H.png) Demo Editor is a new user i added with Editor status and then logged in as Demo Editor and modified a post to test this solution works. You can create a custom template tag in your child theme l...
144,051
<p>I developing some scrapping plugin for my own purpose. So each 10 minutes i need to start my plugin from the cron. Plugin will parse some posts from other pages and add it to wp. So is it possible to load plugin with wp core from console?</p>
[ { "answer_id": 144052, "author": "Blake", "author_id": 27771, "author_profile": "https://wordpress.stackexchange.com/users/27771", "pm_score": -1, "selected": false, "text": "<p>You can load Wordpress core anywhere.</p>\n\n<p>require_once('/../../../wp-blog-header.php'); // Use actual ro...
2014/05/11
[ "https://wordpress.stackexchange.com/questions/144051", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24380/" ]
I developing some scrapping plugin for my own purpose. So each 10 minutes i need to start my plugin from the cron. Plugin will parse some posts from other pages and add it to wp. So is it possible to load plugin with wp core from console?
While the idea that you are "developing some scrapping plugin" is sketchy and off-putting, the general question is "How do I fire code using system cron jobs?" and that is a valid question. You don't need to jump through hoops to load WordPress. Set up an [AJAX API callback](http://codex.wordpress.org/AJAX_in_Plugins)...
144,063
<p>I have inherited the job of editing my agency's webpage. I didn't create the site, and I am not sure whether the IMW custom theme that is active is a child type theme for 2011, or whether all customizations up to this point have been made to the original theme. Do need to create a child theme for this site, how to ...
[ { "answer_id": 144065, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 4, "selected": false, "text": "<ul>\n<li>Read the stylesheet. A child stylesheet <strong><em>must have</em></strong> <code>Template:\nsomethem...
2014/05/11
[ "https://wordpress.stackexchange.com/questions/144063", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51523/" ]
I have inherited the job of editing my agency's webpage. I didn't create the site, and I am not sure whether the IMW custom theme that is active is a child type theme for 2011, or whether all customizations up to this point have been made to the original theme. Do need to create a child theme for this site, how to do t...
* Read the stylesheet. A child stylesheet ***must have*** `Template: somethemename` to function as a child theme. * Look in Appearance -> Themes. A child theme should have a notice about requiring a parent theme. * Use code similar to this (note: debugging only): ``` add_action( 'wp_head', function () { if (ge...
144,078
<p>I would like to list all posts that have a key of <code>cp_annonceur</code> with the value <code>professionnel</code>.</p>
[ { "answer_id": 144079, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 6, "selected": false, "text": "<p>What you are asking for is a <code>meta_query</code></p>\n<pre><code>$args = array(\n 'meta_key' =&gt; 'cu...
2014/05/11
[ "https://wordpress.stackexchange.com/questions/144078", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51533/" ]
I would like to list all posts that have a key of `cp_annonceur` with the value `professionnel`.
What you are asking for is a `meta_query` ``` $args = array( 'meta_key' => 'custom-meta-key', 'meta_query' => array( array( 'key' => 'cp_annonceur', 'value' => 'professionnel', 'compare' => '=', ) ) ); $query = new WP_Query($args); ``` [All of the information y...
144,099
<p>Which theme details are absolutely required for your style.css file header?</p> <p>I'm developing my first theme for personal use, so do I really have to include things like a license, license uri, author, author uri, etc.</p> <p>WordPress Docs just give an example, but they don't reference what's required. Does a...
[ { "answer_id": 144103, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 3, "selected": true, "text": "<p>A quick test indicates that you don't actually need anything in that header for standalone theme. A theme wit...
2014/05/12
[ "https://wordpress.stackexchange.com/questions/144099", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35801/" ]
Which theme details are absolutely required for your style.css file header? I'm developing my first theme for personal use, so do I really have to include things like a license, license uri, author, author uri, etc. WordPress Docs just give an example, but they don't reference what's required. Does anyone know? ``` ...
A quick test indicates that you don't actually need anything in that header for standalone theme. A theme with a completely blank header registers and loads just fine, both front and back end. If it is a child theme you need the `Template:` line. However... > > > > > > In addition to CSS style information for you...
144,149
<p>i'm writing a little action plugin. everytime a new post is created, a new table should be created in an external db. The name of the table sholud reflect the post_id of the newly created post, but i can0t figure how to pass it.</p> <p>Here's my code so far (for php purists, forgive me for using old mysql_connect (...
[ { "answer_id": 144103, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 3, "selected": true, "text": "<p>A quick test indicates that you don't actually need anything in that header for standalone theme. A theme wit...
2014/05/12
[ "https://wordpress.stackexchange.com/questions/144149", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51568/" ]
i'm writing a little action plugin. everytime a new post is created, a new table should be created in an external db. The name of the table sholud reflect the post\_id of the newly created post, but i can0t figure how to pass it. Here's my code so far (for php purists, forgive me for using old mysql\_connect (but addi...
A quick test indicates that you don't actually need anything in that header for standalone theme. A theme with a completely blank header registers and loads just fine, both front and back end. If it is a child theme you need the `Template:` line. However... > > > > > > In addition to CSS style information for you...
144,156
<p>I've created a submenu in wordpress using add_submenu_page:</p> <pre><code>add_submenu_page(null,'Page Title','Page Title','administrator','page-slug','page-callback'); </code></pre> <p>I want to create another page like this with the condition that the page will be totally blank without creating a new file does w...
[ { "answer_id": 144159, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": false, "text": "<p>Don't try to do this with admin menus/ admin pages. It is going to be a headache. Set up an <a href=\"http:/...
2014/05/12
[ "https://wordpress.stackexchange.com/questions/144156", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37040/" ]
I've created a submenu in wordpress using add\_submenu\_page: ``` add_submenu_page(null,'Page Title','Page Title','administrator','page-slug','page-callback'); ``` I want to create another page like this with the condition that the page will be totally blank without creating a new file does wordpress have a function...
Try something like this: in the load hook, you can ouput your xml code. u ``` function my_menu_pages() { $hook = add_submenu_page( null, 'Page Title', 'Page Title', 'administrator', 'sub-menu-slug', function() { } ); add_action('load-' . $hook, function() { // add your xml code he...
144,163
<p><strong>UPDATE:</strong> My question is not offtopic, because WordPress crops the logo image and not just CSS.</p> <p>I'm trying to use a 4724 × 2362 png image as a site logo at the top of <a href="http://slova.de" rel="nofollow noreferrer">a WordPress website</a> with the stock Twenty Thirteen theme.</p> <p>By de...
[ { "answer_id": 144171, "author": "KnightHawk", "author_id": 50492, "author_profile": "https://wordpress.stackexchange.com/users/50492", "pm_score": 1, "selected": false, "text": "<p>If you are using a recent version of wordpress it gives you the option of changing the header image in the...
2014/05/12
[ "https://wordpress.stackexchange.com/questions/144163", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41372/" ]
**UPDATE:** My question is not offtopic, because WordPress crops the logo image and not just CSS. I'm trying to use a 4724 × 2362 png image as a site logo at the top of [a WordPress website](http://slova.de) with the stock Twenty Thirteen theme. By default the image height is cropped (here [fullscreen](https://i.stac...
First of all, do not change any files in the twenty thirteen theme. The reason been, twenty thirteen is updated regulary, so if you made changes to the theme, you **WILL** loose everything you have done to the theme. You should create a [child theme](http://codex.wordpress.org/Child_Themes) You need to change the func...
144,165
<p>Let's say I have a plugin that's currently at version 1.1, and I am releasing version 1.2. When you run the 1.2 update, a script will run to add new options, columns, tables, etc.</p> <p>A month later, 1.3 is released. Do I still need to include the update scripts in version 1.2 so people can update the plugin from...
[ { "answer_id": 144177, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 3, "selected": true, "text": "<blockquote>\n <p>Do I still need to include the update scripts in version 1.2 so people can update the plugi...
2014/05/12
[ "https://wordpress.stackexchange.com/questions/144165", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50444/" ]
Let's say I have a plugin that's currently at version 1.1, and I am releasing version 1.2. When you run the 1.2 update, a script will run to add new options, columns, tables, etc. A month later, 1.3 is released. Do I still need to include the update scripts in version 1.2 so people can update the plugin from v1.1 *dir...
> > Do I still need to include the update scripts in version 1.2 so people can update the plugin from v1.1 directly to v1.3? > > > Yes. > > Is there a way for WordPress to automatically download v1.2, run the update scripts, and then download v1.3... > > > No. > > ...is there a way to flag v1.3 of my plugi...
144,166
<p>I'm trying to include a jQuery autocomplete script in the header.php file of my theme. </p> <p>The script, outside of wordpress, works great using this structure (which is the same as the jQuery autocomplete demo):</p> <pre><code>&lt;script&gt; $(function() { ..... }); &lt;/script&gt; </code></pre> <p>...
[ { "answer_id": 144170, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 2, "selected": false, "text": "<p>There are a couple of ways to achieve this. I think the following methods are the best to use.</p>\n\n<...
2014/05/12
[ "https://wordpress.stackexchange.com/questions/144166", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37934/" ]
I'm trying to include a jQuery autocomplete script in the header.php file of my theme. The script, outside of wordpress, works great using this structure (which is the same as the jQuery autocomplete demo): ``` <script> $(function() { ..... }); </script> ``` I've tried wrapping it like this: ``` <scri...
As I stated in the comments. You need to have jQuery and jQuery UI loaded in order to use the autocomplete UI. I modified your hook to have dependencies on the required libraries. Now all you need to do is set the path to your custom js file that initializes autocomplete. The dependencies will load the files needed as ...
144,172
<p>I'm trying to make scripts load in a certain order, and am getting unexpected results. I'm using this script:</p> <pre><code>function tallulah_scripts() { wp_enqueue_script( 'header-js', get_template_directory_uri() . '/js/header.min.js', null, '1.0', false ); wp_deregister_script('jquery'); wp_enqueue_script...
[ { "answer_id": 144175, "author": "pascalvgemert", "author_id": 25063, "author_profile": "https://wordpress.stackexchange.com/users/25063", "pm_score": 1, "selected": false, "text": "<p>Check out the following url: <a href=\"http://www.trembl.org/codec/832/\" rel=\"nofollow\">http://www.t...
2014/05/12
[ "https://wordpress.stackexchange.com/questions/144172", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10755/" ]
I'm trying to make scripts load in a certain order, and am getting unexpected results. I'm using this script: ``` function tallulah_scripts() { wp_enqueue_script( 'header-js', get_template_directory_uri() . '/js/header.min.js', null, '1.0', false ); wp_deregister_script('jquery'); wp_enqueue_script( 'footer-js',...
Simple Fix ---------- The reason why your code does not work is because the third parameter of the [`wp_enqueue_script()`](http://codex.wordpress.org/Function_Reference/wp_enqueue_script) function is expecting an **array**, not a string. Just replace `'footer-js'` with `array('footer-js')` and it will work: ``` func...
144,179
<p>I'm looking to modify how Wordpress is showing the pages of my posts. What I currently have is a previous and next page link at the bottom of the post with the following code:</p> <pre><code>&lt;?php wp_link_pages( array( 'before' =&gt; '&lt;div class="page-link-next-prev"&gt;', 'after' =&gt; '&lt;/div&gt;', 'next...
[ { "answer_id": 144212, "author": "Craig Pearson", "author_id": 17295, "author_profile": "https://wordpress.stackexchange.com/users/17295", "pm_score": 4, "selected": true, "text": "<p>This code should help you achieve what you want to, if you swap the code below</p>\n\n<pre><code>&lt;?ph...
2014/05/12
[ "https://wordpress.stackexchange.com/questions/144179", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51578/" ]
I'm looking to modify how Wordpress is showing the pages of my posts. What I currently have is a previous and next page link at the bottom of the post with the following code: ``` <?php wp_link_pages( array( 'before' => '<div class="page-link-next-prev">', 'after' => '</div>', 'next_or_number' => 'next', 'previouspag...
This code should help you achieve what you want to, if you swap the code below ``` <?php wp_link_pages( array( 'before' => '<div class="page-link-next-prev">', 'after' => '</div>', 'next_or_number' => 'next', 'previouspagelink' => __('Previous'), 'nextpagelink'=> __('Next') ) );?> ``` With this code ``` <?php ...
144,203
<p>I have installed Wordpress 3.9.1 on wampserver2.2e-php5.3.13-httpd2.2.22-mysql5.5.24-x64. Then I installed the Facebook Plugin (1.5.5). I created a Facebook app and than I wanted to enter the credentials in the Facebook plugin. I get the following error message:</p> <blockquote> <p>Your server does not support co...
[ { "answer_id": 144207, "author": "Craig Pearson", "author_id": 17295, "author_profile": "https://wordpress.stackexchange.com/users/17295", "pm_score": 1, "selected": false, "text": "<p>I imagine this is because <code>php_curl</code> extension hasn't been enabled in wamp. You can try to e...
2014/05/12
[ "https://wordpress.stackexchange.com/questions/144203", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13921/" ]
I have installed Wordpress 3.9.1 on wampserver2.2e-php5.3.13-httpd2.2.22-mysql5.5.24-x64. Then I installed the Facebook Plugin (1.5.5). I created a Facebook app and than I wanted to enter the credentials in the Facebook plugin. I get the following error message: > > Your server does not support communication with Fac...
I imagine this is because `php_curl` extension hasn't been enabled in wamp. You can try to enable curl and then restart wamp. If you have a tray icon for wamp you can left click on the tray icon, choose PHP -> PHP Extensions and enable `php_curl`. Then left click the icon again and this time select Restart All Service...
144,312
<p>it's been a while since I used wordpress and I am trying to us e advanced custom fields, I am trying to output the post ID inside a loop on a page, so i can use get_field to output the post contents. Ths $post->ID gives me the page id not the post id so thr wrong number is being outputted, how do I get the post ID?<...
[ { "answer_id": 144314, "author": "certainstrings", "author_id": 14998, "author_profile": "https://wordpress.stackexchange.com/users/14998", "pm_score": 0, "selected": false, "text": "<p>Use wp_query() with your params instead. Query_posts slows down your queries. <a href=\"http://codex...
2014/05/13
[ "https://wordpress.stackexchange.com/questions/144312", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7653/" ]
it's been a while since I used wordpress and I am trying to us e advanced custom fields, I am trying to output the post ID inside a loop on a page, so i can use get\_field to output the post contents. Ths $post->ID gives me the page id not the post id so thr wrong number is being outputted, how do I get the post ID? `...
Dont use `query_posts` or `WP_Query` if you need it in the main loop. Dont ever use `query_posts` anyway. ``` <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php $current_id = get_the_ID(); ?> <?php echo $current_id ?> <h1><?php the_field('titleFart', $current_id); ?></h1> <?...
144,325
<p>I need to know if there's a way to remove the <code>register</code> button on the WordPress login page along with the link to the <code>registration form</code> ... without messing with core files ... so that I don't get just "anyone" (or spammers) setting up accounts!</p> <p>I do, however, still need the <code>use...
[ { "answer_id": 144326, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 2, "selected": true, "text": "<p>There's a \"Membership\" setting under Settings > General. By disabling \"Anyone can register\" the publi...
2014/05/13
[ "https://wordpress.stackexchange.com/questions/144325", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40491/" ]
I need to know if there's a way to remove the `register` button on the WordPress login page along with the link to the `registration form` ... without messing with core files ... so that I don't get just "anyone" (or spammers) setting up accounts! I do, however, still need the `user registration` function to work. I...
There's a "Membership" setting under Settings > General. By disabling "Anyone can register" the public-facing registration page will be effectively removed, along with the 'register' button. The API, however, will still be usable (e.g. `wp_create_user()`.) On a side note, you mention > > NOTE: I'm working in a plug...
144,340
<p>I am trying to display post view counts.</p> <p>I've tried below function to display the post view count, but I'm getting same post view for all the post in loop. Not getting correct post view count.</p> <p><strong>Function:</strong></p> <pre><code> &lt;?php // function to display number of posts....
[ { "answer_id": 144347, "author": "Chittaranjan", "author_id": 43031, "author_profile": "https://wordpress.stackexchange.com/users/43031", "pm_score": 1, "selected": false, "text": "<p>If you are storing the meta data correctly, then you can use the following code to display the count</p>...
2014/05/14
[ "https://wordpress.stackexchange.com/questions/144340", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/44040/" ]
I am trying to display post view counts. I've tried below function to display the post view count, but I'm getting same post view for all the post in loop. Not getting correct post view count. **Function:** ``` <?php // function to display number of posts. function getPostViews($postID){ ...
Add this to single.php, and make sure you paste in inside the loop. ``` <?php setPostViews(get_the_ID()); ?> ``` Lastly, to display the number of views a post has, just add this where you want it to be displayed: ``` <?php echo getPostViews(get_the_ID()); ?> ``` . ``` <?php // function to display number of post...
144,364
<p>I want to change the Theme's interface language without making multisite by passing langauage parameter into the URL.</p> <pre><code>&lt;a href="&lt;?php echo home_url('/')?lang=bn ?&gt;"&gt;Bengali&lt;/a&gt; </code></pre> <p>My thought is to use the following code:</p> <pre><code>if(get_query_var('bn')) { /...
[ { "answer_id": 149012, "author": "Mayeenul Islam", "author_id": 22728, "author_profile": "https://wordpress.stackexchange.com/users/22728", "pm_score": 0, "selected": false, "text": "<p><strong>Trigger in template:</strong></p>\n\n<pre><code>&lt;a href=\"?lang=bn\"&gt;BN&lt;/a&gt;|&lt;a ...
2014/05/14
[ "https://wordpress.stackexchange.com/questions/144364", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22728/" ]
I want to change the Theme's interface language without making multisite by passing langauage parameter into the URL. ``` <a href="<?php echo home_url('/')?lang=bn ?>">Bengali</a> ``` My thought is to use the following code: ``` if(get_query_var('bn')) { /** * CHANGE THE 'WPLANG' IN wp-config.php TO bn_BD...
2 notes regarding [your own answer](https://wordpress.stackexchange.com/a/149012/35541): * try to not access on super global variables directly, but using [`filter_input`](http://www.php.net/manual/en/function.filter-input.php) * your code throw a notice if `$_GET['lang']` is not set So your code can be improved: ``...
144,366
<p>I have a multisite install of WordPress. I have installed the plugin Monkeyman Rewrite Analyzer so I can see all the rules I have registered. The code below is how I am registering the rule:</p> <pre><code> add_action( 'init', 'add_init_rules' ); function add_init_rules() { add_rewrite_rule('^car/([^/]*)/([^...
[ { "answer_id": 149012, "author": "Mayeenul Islam", "author_id": 22728, "author_profile": "https://wordpress.stackexchange.com/users/22728", "pm_score": 0, "selected": false, "text": "<p><strong>Trigger in template:</strong></p>\n\n<pre><code>&lt;a href=\"?lang=bn\"&gt;BN&lt;/a&gt;|&lt;a ...
2014/05/14
[ "https://wordpress.stackexchange.com/questions/144366", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51634/" ]
I have a multisite install of WordPress. I have installed the plugin Monkeyman Rewrite Analyzer so I can see all the rules I have registered. The code below is how I am registering the rule: ``` add_action( 'init', 'add_init_rules' ); function add_init_rules() { add_rewrite_rule('^car/([^/]*)/([^/]*)/?','index...
2 notes regarding [your own answer](https://wordpress.stackexchange.com/a/149012/35541): * try to not access on super global variables directly, but using [`filter_input`](http://www.php.net/manual/en/function.filter-input.php) * your code throw a notice if `$_GET['lang']` is not set So your code can be improved: ``...
144,371
<p>I am new to WordPress plugin development and i am stuck at why the wordpress function <code>add_options_page()</code> is not accepting role. </p> <p>This is my code which is not working</p> <pre><code>add_action('admin_menu', 'ct_admin_settings_page'); function ct_admin_settings_page() { add_options_page( ...
[ { "answer_id": 149012, "author": "Mayeenul Islam", "author_id": 22728, "author_profile": "https://wordpress.stackexchange.com/users/22728", "pm_score": 0, "selected": false, "text": "<p><strong>Trigger in template:</strong></p>\n\n<pre><code>&lt;a href=\"?lang=bn\"&gt;BN&lt;/a&gt;|&lt;a ...
2014/05/14
[ "https://wordpress.stackexchange.com/questions/144371", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51683/" ]
I am new to WordPress plugin development and i am stuck at why the wordpress function `add_options_page()` is not accepting role. This is my code which is not working ``` add_action('admin_menu', 'ct_admin_settings_page'); function ct_admin_settings_page() { add_options_page( 'CT Settings', 'CT S...
2 notes regarding [your own answer](https://wordpress.stackexchange.com/a/149012/35541): * try to not access on super global variables directly, but using [`filter_input`](http://www.php.net/manual/en/function.filter-input.php) * your code throw a notice if `$_GET['lang']` is not set So your code can be improved: ``...
144,405
<p>I am using the code below on a multi user blog for sending a email notification to users when new post is published . But the problem is it is sending notification only when a Administrator and Editor is posting. I want to send notification when a Administrator, Editor, Author and Contributor post any thing. So what...
[ { "answer_id": 149012, "author": "Mayeenul Islam", "author_id": 22728, "author_profile": "https://wordpress.stackexchange.com/users/22728", "pm_score": 0, "selected": false, "text": "<p><strong>Trigger in template:</strong></p>\n\n<pre><code>&lt;a href=\"?lang=bn\"&gt;BN&lt;/a&gt;|&lt;a ...
2014/05/14
[ "https://wordpress.stackexchange.com/questions/144405", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51696/" ]
I am using the code below on a multi user blog for sending a email notification to users when new post is published . But the problem is it is sending notification only when a Administrator and Editor is posting. I want to send notification when a Administrator, Editor, Author and Contributor post any thing. So what sh...
2 notes regarding [your own answer](https://wordpress.stackexchange.com/a/149012/35541): * try to not access on super global variables directly, but using [`filter_input`](http://www.php.net/manual/en/function.filter-input.php) * your code throw a notice if `$_GET['lang']` is not set So your code can be improved: ``...
144,425
<p>What hook is executed just after wp_query has been executed? before template is rendered? I want to change the page title but it depends on what has been queried.</p> <p>I have put it in template_redirect but not sure if it is the right hook</p>
[ { "answer_id": 149012, "author": "Mayeenul Islam", "author_id": 22728, "author_profile": "https://wordpress.stackexchange.com/users/22728", "pm_score": 0, "selected": false, "text": "<p><strong>Trigger in template:</strong></p>\n\n<pre><code>&lt;a href=\"?lang=bn\"&gt;BN&lt;/a&gt;|&lt;a ...
2014/05/14
[ "https://wordpress.stackexchange.com/questions/144425", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50109/" ]
What hook is executed just after wp\_query has been executed? before template is rendered? I want to change the page title but it depends on what has been queried. I have put it in template\_redirect but not sure if it is the right hook
2 notes regarding [your own answer](https://wordpress.stackexchange.com/a/149012/35541): * try to not access on super global variables directly, but using [`filter_input`](http://www.php.net/manual/en/function.filter-input.php) * your code throw a notice if `$_GET['lang']` is not set So your code can be improved: ``...
144,426
<p>For the search results page Im making a custom template. And in that custom template I want to display custom meta field values.</p> <p>However, when I do this:</p> <pre><code> &lt;?php if ( have_posts() ) : ?&gt; &lt;?php /* Start the Loop */ ?&gt; &lt;?php while ( have_posts() ) : the_post();...
[ { "answer_id": 144427, "author": "Craig Pearson", "author_id": 17295, "author_profile": "https://wordpress.stackexchange.com/users/17295", "pm_score": 1, "selected": false, "text": "<p>You've got a missing <code>)</code> and you're passing true as a string and not a boolean value. So thi...
2014/05/14
[ "https://wordpress.stackexchange.com/questions/144426", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47366/" ]
For the search results page Im making a custom template. And in that custom template I want to display custom meta field values. However, when I do this: ``` <?php if ( have_posts() ) : ?> <?php /* Start the Loop */ ?> <?php while ( have_posts() ) : the_post(); ?> <?php $...
You've got a missing `)` and you're passing true as a string and not a boolean value. So this line: ``` $pName = get_post_meta($post->ID, $productName, 'true'; ``` Should in fact be: ``` $pName = get_post_meta($post->ID, $productName, true); ``` In light of your update why not do something like: ``` echo 'Produc...
144,435
<p>When I use the_content in the page-template doesn't show anything.</p> <p>Loop to call the page-template in the index:</p> <p><code>index.php</code></p> <pre><code>&lt;?php /** * Main template file * * This is the most generic template file in a WordPress theme * and one of the two required files for a theme (th...
[ { "answer_id": 144436, "author": "Andrew Lazarus", "author_id": 27504, "author_profile": "https://wordpress.stackexchange.com/users/27504", "pm_score": 2, "selected": false, "text": "<p>Have you tried using the whole loop?</p>\n\n<pre><code>&lt;?php $loop = new WP_Query();\nif ( $loop-&g...
2014/05/14
[ "https://wordpress.stackexchange.com/questions/144435", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47959/" ]
When I use the\_content in the page-template doesn't show anything. Loop to call the page-template in the index: `index.php` ``` <?php /** * Main template file * * This is the most generic template file in a WordPress theme * and one of the two required files for a theme (the other being style.css). * It is use...
SOLVED IN THIS WAY: (index.php) =============================== ``` <?php $args = array( 'child_of' => 0, 'order' => 'ASC', 'orderby' => 'menu_order', 'hierarchical' => 1, 'post_type' => 'page', 'post_status' => 'publish', ...
144,444
<p>I'm new to PHP!</p> <p>I'm trying to import an SQL file using phpMyAdmin through a GoDaddy cPanel(please don't make fun of me)</p> <p>Here's a full readout</p> <pre><code>-- -- Dumping data for table `wp_commentmeta` -- INSERT INTO `wp_commentmeta` (`meta_id`, `comment_id`, `meta_key`, `meta_value`) VALUES (1, 3,...
[ { "answer_id": 144455, "author": "AlexanderR", "author_id": 51627, "author_profile": "https://wordpress.stackexchange.com/users/51627", "pm_score": 1, "selected": false, "text": "<p>From what I can see, you are inserting data in table <code>wp_commentmeta</code>. However the column <code...
2014/05/15
[ "https://wordpress.stackexchange.com/questions/144444", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51700/" ]
I'm new to PHP! I'm trying to import an SQL file using phpMyAdmin through a GoDaddy cPanel(please don't make fun of me) Here's a full readout ``` -- -- Dumping data for table `wp_commentmeta` -- INSERT INTO `wp_commentmeta` (`meta_id`, `comment_id`, `meta_key`, `meta_value`) VALUES (1, 3, 'rating', '5'), (37, 39, 'r...
This is an old problem I had forgotten about. The problem here is that an old database was selected in the left hand menu of phpMyAdmin(read: I'm new to database management). The table was already in use and therefore populated - this error message is because phpMyAdmin tried to write to the first line, couldn't(alread...
144,452
<p>I wanted to pass arguments to a function triggered by an add_action hook. I followed the <a href="http://codex.wordpress.org/Function_Reference/do_action" rel="nofollow">codex on this</a>. I got a warning and the result was erratic, with an unexpected behavior.</p> <p>This question has already been adressed <a href...
[ { "answer_id": 144487, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 0, "selected": false, "text": "<p>From your <a href=\"https://gist.github.com/Nandrine/9d2083c5978c5c229ae0\" rel=\"nofollow\">Gist</a> you ...
2014/05/15
[ "https://wordpress.stackexchange.com/questions/144452", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51503/" ]
I wanted to pass arguments to a function triggered by an add\_action hook. I followed the [codex on this](http://codex.wordpress.org/Function_Reference/do_action). I got a warning and the result was erratic, with an unexpected behavior. This question has already been adressed [before](http://wordpress.org/support/topi...
This problem can be met when hooking in whatever hook that has already been triggered by a precedent `do_action` (ie. when `this_hook` has already been mentionned in a `do_action` within the core files of wordpress or within whatever plugin files) In that particular case, demanding arguments when registering a new fu...
144,457
<p>I am trying to convert a website to WordPress. The URLs in use are currently in the format: <code>http://www.example.com/database/44/category/short-item-description.html</code></p> <p>To display items that are stored in the database, I have created a page template DatabaseFetch.php and have added ...
[ { "answer_id": 144487, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 0, "selected": false, "text": "<p>From your <a href=\"https://gist.github.com/Nandrine/9d2083c5978c5c229ae0\" rel=\"nofollow\">Gist</a> you ...
2014/05/15
[ "https://wordpress.stackexchange.com/questions/144457", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51627/" ]
I am trying to convert a website to WordPress. The URLs in use are currently in the format: `http://www.example.com/database/44/category/short-item-description.html` To display items that are stored in the database, I have created a page template DatabaseFetch.php and have added a page to WordPress to use this templat...
This problem can be met when hooking in whatever hook that has already been triggered by a precedent `do_action` (ie. when `this_hook` has already been mentionned in a `do_action` within the core files of wordpress or within whatever plugin files) In that particular case, demanding arguments when registering a new fu...
144,459
<p>I created a Page called "About Joe" as a <strong><em>page</em></strong> in WordPress.</p> <p>Then on a different page (e.g. the homepage), I wish to display <em>a summary</em> which includes: </p> <ol> <li>a thumbnail</li> <li>the 1st paragraph</li> <li>link to page</li> </ol> <p>Is this possible?</p> <p>Maybe I...
[ { "answer_id": 144478, "author": "pascalvgemert", "author_id": 25063, "author_profile": "https://wordpress.stackexchange.com/users/25063", "pm_score": 1, "selected": false, "text": "<p>Use <code>$post = get_post( id );</code> and then set the post like <code>setup_postdata($post);</code>...
2014/05/15
[ "https://wordpress.stackexchange.com/questions/144459", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12116/" ]
I created a Page called "About Joe" as a ***page*** in WordPress. Then on a different page (e.g. the homepage), I wish to display *a summary* which includes: 1. a thumbnail 2. the 1st paragraph 3. link to page Is this possible? Maybe I'm not asking the right questions to the codex as I'm not finding anything. The...
**Update: No more working tired!** Completely forgot about WP\_Query. Here is what I came up with... ``` <?php $args = array ( 'page_id' => '1265', 'post_type' => 'Page', 'post_status' => 'published', 'posts_per_page' => '1', 'ignore_sticky...
144,460
<p>I just need to debug an array which comes into addfilter function like this:</p> <pre><code>add_filter('pll_copy_post_metas', 'copy_post_metas'); function copy_post_metas($metas) { var_dump($metas); return $metas; } </code></pre> <p>How can I do that to just check what is the value of $metas? </p> <p>This...
[ { "answer_id": 144483, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 2, "selected": true, "text": "<p>When you save a post, then you are basically submitting a big <code>&lt;form&gt;</code>. This form has an action po...
2014/05/15
[ "https://wordpress.stackexchange.com/questions/144460", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51712/" ]
I just need to debug an array which comes into addfilter function like this: ``` add_filter('pll_copy_post_metas', 'copy_post_metas'); function copy_post_metas($metas) { var_dump($metas); return $metas; } ``` How can I do that to just check what is the value of $metas? This filter runs in admin when saving...
When you save a post, then you are basically submitting a big `<form>`. This form has an action pointing somewhere. Now there are two possibilities how the form is processed: 1. AJAX (background reload) 2. Default `<form>` handling (new request) Basic form submitting is adding a new request (2), so the data gets proc...
144,471
<p>I have a page template which has a loop to show blog posts. Inside the loop, there is <code>get_template_part('content', 'custom')</code> function to include the template (content-custom.php) which shows blog post content. Is it possible to get current page ID inside <code>content-custom.php</code> file?</p>
[ { "answer_id": 144472, "author": "Krzysiek Dróżdż", "author_id": 34172, "author_profile": "https://wordpress.stackexchange.com/users/34172", "pm_score": 3, "selected": true, "text": "<p>You can use all <a href=\"http://codex.wordpress.org/Template_Tags\" rel=\"nofollow\">template tags</a...
2014/05/15
[ "https://wordpress.stackexchange.com/questions/144471", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40607/" ]
I have a page template which has a loop to show blog posts. Inside the loop, there is `get_template_part('content', 'custom')` function to include the template (content-custom.php) which shows blog post content. Is it possible to get current page ID inside `content-custom.php` file?
You can use all [template tags](http://codex.wordpress.org/Template_Tags) inside this file, so to get the ID, just use [`get_the_ID()`](http://codex.wordpress.org/Function_Reference/get_the_ID) (or [`the_ID()`](http://codex.wordpress.org/Function_Reference/the_ID) to output it). `get_the_ID()` will retrieve the numeri...
144,481
<p>I'm writing a custom form on my plugin settings area. </p> <pre><code>&lt;form action="&lt;?php echo admin_url('options-general.php?page=yasr_settings_page') ?&gt;" id="form_add_multi_set"&gt; &lt;strong&gt;Name&lt;/strong&gt; &lt;input type="text" name="multi-set-name" id="new-multi-set-na...
[ { "answer_id": 144554, "author": "scottsawyer", "author_id": 51748, "author_profile": "https://wordpress.stackexchange.com/users/51748", "pm_score": 0, "selected": false, "text": "<p>According to the codex, <a href=\"http://codex.wordpress.org/Creating_Options_Pages\" rel=\"nofollow\">Cr...
2014/05/15
[ "https://wordpress.stackexchange.com/questions/144481", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48442/" ]
I'm writing a custom form on my plugin settings area. ``` <form action="<?php echo admin_url('options-general.php?page=yasr_settings_page') ?>" id="form_add_multi_set"> <strong>Name</strong> <input type="text" name="multi-set-name" id="new-multi-set-name" class="input-text-multi-set"> ...
Just add the attribute `method="post"` within the `form` element. That's it :) Happy coding!
144,492
<p>I want to change my custom post URL. I want to remove "<strong>item</strong>" from URL.</p> <p>With the below code and with custom post type url plugin <a href="http://wordpress.org/plugins/custom-post-type-permalinks/" rel="nofollow">http://wordpress.org/plugins/custom-post-type-permalinks/</a> my URL is:</p> <p>...
[ { "answer_id": 144554, "author": "scottsawyer", "author_id": 51748, "author_profile": "https://wordpress.stackexchange.com/users/51748", "pm_score": 0, "selected": false, "text": "<p>According to the codex, <a href=\"http://codex.wordpress.org/Creating_Options_Pages\" rel=\"nofollow\">Cr...
2014/05/15
[ "https://wordpress.stackexchange.com/questions/144492", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18970/" ]
I want to change my custom post URL. I want to remove "**item**" from URL. With the below code and with custom post type url plugin <http://wordpress.org/plugins/custom-post-type-permalinks/> my URL is: Original URL : **`http://mywebsite/wp/item/america/mayer/`** Want to change it to **`http://mywebsite/wp/america/m...
Just add the attribute `method="post"` within the `form` element. That's it :) Happy coding!
144,498
<p>I'm having a lot of trouble registering scripts located in a child theme folder:</p> <p>This works fine:</p> <pre><code>function register_scripts() { wp_register_script( 'newsletter', get_template_directory_uri() . '/scripts/scripts.js', array( 'jquery-migrate' ), null ); } add_action( 'init', 'register_script...
[ { "answer_id": 144502, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": false, "text": "<p>I don't see how the first block of code works and not the second since in both cases all you are doing is <e...
2014/05/15
[ "https://wordpress.stackexchange.com/questions/144498", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2488/" ]
I'm having a lot of trouble registering scripts located in a child theme folder: This works fine: ``` function register_scripts() { wp_register_script( 'newsletter', get_template_directory_uri() . '/scripts/scripts.js', array( 'jquery-migrate' ), null ); } add_action( 'init', 'register_scripts' ); ``` However i...
I think that none the options you has posted actually works. You are only registering the script, you need to enqeue them. Also, you should use `wp_enqueue_scripts()` action hook instead of `init()`. ``` function register_scripts() { wp_register_script( 'newsletter', get_stylesheet_directory_uri() . '/scri...
144,507
<p>As a WordPress newbie I am trying to create a plugin, which will force users to specify their <strong>city</strong> and <strong>gender</strong> while registering and then display a personal profile page for each user showing this information.</p> <p>I have checked in my plugin in GitHub: <a href="https://github.com/...
[ { "answer_id": 144802, "author": "Nicolai Grossherr", "author_id": 22534, "author_profile": "https://wordpress.stackexchange.com/users/22534", "pm_score": 3, "selected": true, "text": "<p>I think an easy way to do this would be to make use of the wordpress template structure, take a look...
2014/05/15
[ "https://wordpress.stackexchange.com/questions/144507", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41372/" ]
As a WordPress newbie I am trying to create a plugin, which will force users to specify their **city** and **gender** while registering and then display a personal profile page for each user showing this information. I have checked in my plugin in GitHub: [wp-city-gender.php](https://github.com/afarber/wp-newbie/blob/...
I think an easy way to do this would be to make use of the wordpress template structure, take a look at [Codex: Templates](http://codex.wordpress.org/Templates) and [Codex: Template Hierarchy](http://codex.wordpress.org/Template_Hierarchy) for a general overview. But namely you could use the author templates - [Codex: ...
144,583
<p>On the Dashboard tab in wp-admin in my user account, I have certain items hidden in Screen Options and I have the panels arranged in a particular way.</p> <p>I want to copy the same layout to my other administrative users, so that they can see certain information and so that I can more easily remotely explain thing...
[ { "answer_id": 144607, "author": "Brandt Solovij", "author_id": 38927, "author_profile": "https://wordpress.stackexchange.com/users/38927", "pm_score": 1, "selected": false, "text": "<p>Take a look in the Database in the <code>{$prefix}usermeta</code> table. There is a field named:</p>\n...
2014/05/16
[ "https://wordpress.stackexchange.com/questions/144583", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/961/" ]
On the Dashboard tab in wp-admin in my user account, I have certain items hidden in Screen Options and I have the panels arranged in a particular way. I want to copy the same layout to my other administrative users, so that they can see certain information and so that I can more easily remotely explain things when I n...
### Original code (License: MIT) The following code is altered [from my "Meta Box Order debug" plugin](https://gist.github.com/franz-josef-kaiser/9100450) (available on GitHub as Gist). The explanation can be found in the code comments. ### Benefit The nice thing with this solution is, that it does *not* alter the ...
144,602
<p>I have used some of the tutorials out there to convert a Drupal 7 site over to WordPress. My problem is that I am not finding any tutorials with the lines I can use in my MySQL to convert the users,comments,tags,category table in Drupal 7 over to the wp_users table in WordPress 3+. As I said... everything else has c...
[ { "answer_id": 144607, "author": "Brandt Solovij", "author_id": 38927, "author_profile": "https://wordpress.stackexchange.com/users/38927", "pm_score": 1, "selected": false, "text": "<p>Take a look in the Database in the <code>{$prefix}usermeta</code> table. There is a field named:</p>\n...
2014/05/16
[ "https://wordpress.stackexchange.com/questions/144602", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51531/" ]
I have used some of the tutorials out there to convert a Drupal 7 site over to WordPress. My problem is that I am not finding any tutorials with the lines I can use in my MySQL to convert the users,comments,tags,category table in Drupal 7 over to the wp\_users table in WordPress 3+. As I said... everything else has con...
### Original code (License: MIT) The following code is altered [from my "Meta Box Order debug" plugin](https://gist.github.com/franz-josef-kaiser/9100450) (available on GitHub as Gist). The explanation can be found in the code comments. ### Benefit The nice thing with this solution is, that it does *not* alter the ...
144,605
<p>I'm using <code>WP_Query</code> to get all pages without subpages. For each page I'm using again <code>WP_Query</code> to get all child pages of the current page inside the first loop.</p> <p>This all works fine and I'm getting the expected result.</p> <p>But when now using a third <code>WP_Query</code> on one of ...
[ { "answer_id": 144606, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 2, "selected": false, "text": "<p>This can be done in a single query:</p>\n\n<pre><code>$parent_only = new WP_Query( array(\n 'post_parent' =&gt;...
2014/05/16
[ "https://wordpress.stackexchange.com/questions/144605", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31527/" ]
I'm using `WP_Query` to get all pages without subpages. For each page I'm using again `WP_Query` to get all child pages of the current page inside the first loop. This all works fine and I'm getting the expected result. But when now using a third `WP_Query` on one of the sub pages, the second level loop breaks. I al...
I just found the answer. I think I had another issue anywhere so my real problem could not be solved. I did it like this: In the page templates at first I'm doing ``` global $post; $saved_post = $post; ``` and at the end of the page templates this: ``` if($saved_post) { $post = $saved_post; } ``` I have two ...
144,628
<p>I am creating my own posts in wordpress however I have hit a little problem and im not sure how to fix it.</p> <p>The below register_post_type creates an Invalid post type error.</p> <pre><code>add_action( 'init', 'create_post_type' ); function create_post_type() { register_post_type( 'talent', array( ...
[ { "answer_id": 144629, "author": "Gareth Gillman", "author_id": 33936, "author_profile": "https://wordpress.stackexchange.com/users/33936", "pm_score": 3, "selected": true, "text": "<p>If you can't get the \"talent\" post type to register, set the name to artist and then using the Rewrit...
2014/05/17
[ "https://wordpress.stackexchange.com/questions/144628", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51147/" ]
I am creating my own posts in wordpress however I have hit a little problem and im not sure how to fix it. The below register\_post\_type creates an Invalid post type error. ``` add_action( 'init', 'create_post_type' ); function create_post_type() { register_post_type( 'talent', array( 'labels' => array( ...
If you can't get the "talent" post type to register, set the name to artist and then using the Rewrite option for the CPT e.g. ``` 'rewrite' => array( 'slug' => 'talent' ), ``` That will give you the URL you desire
144,648
<p>I'm having a problem where media isn't showing up on the Category page. (It's actually the exact same problem that's described in <a href="http://wordpress.org/support/topic/embedded-images-and-videos-not-showing-in-archive-and-category-view" rel="nofollow">this WordPress.org forum post</a>, but it's so out of date ...
[ { "answer_id": 144649, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 1, "selected": false, "text": "<p>Your entry.php template is completely wrong. This should be your loop so to speak. Yet this is more lik...
2014/05/17
[ "https://wordpress.stackexchange.com/questions/144648", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4109/" ]
I'm having a problem where media isn't showing up on the Category page. (It's actually the exact same problem that's described in [this WordPress.org forum post](http://wordpress.org/support/topic/embedded-images-and-videos-not-showing-in-archive-and-category-view), but it's so out of date that the solution doesn't app...
Your entry.php template is completely wrong. This should be your loop so to speak. Yet this is more like a page template, that also calls for entry.php. This template should include the call to your `the_content()`, media files, comments if applicable, and the title, also all other things you might want to include in y...
144,651
<p>I am wondering if querying posts like this:</p> <pre><code> &lt;?php $args = array('numberposts' =&gt; 19, 'orderby' =&gt; 'rand' ); $posts = get_posts( $args ); foreach($posts as $post) { $url = get_the_title($post-&gt;ID); echo '&lt;span class="url"&gt;'.$image_url.'&lt;/span...
[ { "answer_id": 144659, "author": "Tejaswini", "author_id": 51682, "author_profile": "https://wordpress.stackexchange.com/users/51682", "pm_score": 0, "selected": false, "text": "<p>get_posts is executed as a single SELECT query on WordPress DB. So pulling 19 random posts from 4000+ posts...
2014/05/17
[ "https://wordpress.stackexchange.com/questions/144651", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/44504/" ]
I am wondering if querying posts like this: ``` <?php $args = array('numberposts' => 19, 'orderby' => 'rand' ); $posts = get_posts( $args ); foreach($posts as $post) { $url = get_the_title($post->ID); echo '<span class="url">'.$image_url.'</span>'; echo '<span cla...
The "Order By Rand() Alternative" method ---------------------------------------- You can check out [this article](http://www.warpconduit.net/2011/03/23/selecting-a-random-record-using-mysql-benchmark-results/) that discuss how to optimize SQL queries when selecting `N` random rows. It's called *Order By Rand() Altern...
144,676
<p>I have been stuck on this for days, reading articles and articles and nothing works. I am trying to display the value of my metabox on a template page. </p> <p>I successfully added the metabox, and I see the select box in my page admin, it also seems to be saving fine.</p> <p>I just can't seem to get the selected ...
[ { "answer_id": 186303, "author": "Mom-again", "author_id": 71636, "author_profile": "https://wordpress.stackexchange.com/users/71636", "pm_score": 0, "selected": false, "text": "<p>display by ID: if 'id' => 'my-meta-box-2', then \nID, 'my-meta-box-2', true );\n?>\nif you are using the r...
2014/05/18
[ "https://wordpress.stackexchange.com/questions/144676", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51787/" ]
I have been stuck on this for days, reading articles and articles and nothing works. I am trying to display the value of my metabox on a template page. I successfully added the metabox, and I see the select box in my page admin, it also seems to be saving fine. I just can't seem to get the selected category in the m...
> > Try this > > > * For `single` template `global $post;` `echo get_post_meta( $post->ID , 'sm_taxonomy', true );` OR * For `archive` template `if ( have_posts() ) : while ( have_posts() ) : the_post();` `echo get_post_meta( get_the_ID() , 'sm_taxonomy', true );` `endif;`
144,677
<p>I'm trying to retrieve a specific category within a custom post type of portfolio. I don't know what I have to put in the query to only get certain posts? Here is what I have so far:</p> <pre><code>&lt;?php // Create and run custom loop $custom_posts = new WP_Query(); $custom_posts-&gt;query('post_type=po...
[ { "answer_id": 186303, "author": "Mom-again", "author_id": 71636, "author_profile": "https://wordpress.stackexchange.com/users/71636", "pm_score": 0, "selected": false, "text": "<p>display by ID: if 'id' => 'my-meta-box-2', then \nID, 'my-meta-box-2', true );\n?>\nif you are using the r...
2014/05/18
[ "https://wordpress.stackexchange.com/questions/144677", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51786/" ]
I'm trying to retrieve a specific category within a custom post type of portfolio. I don't know what I have to put in the query to only get certain posts? Here is what I have so far: ``` <?php // Create and run custom loop $custom_posts = new WP_Query(); $custom_posts->query('post_type=portfolio&posts_per_page...
> > Try this > > > * For `single` template `global $post;` `echo get_post_meta( $post->ID , 'sm_taxonomy', true );` OR * For `archive` template `if ( have_posts() ) : while ( have_posts() ) : the_post();` `echo get_post_meta( get_the_ID() , 'sm_taxonomy', true );` `endif;`
144,680
<p>I am looking for a way to restrict access to mp3 files on my site to logged in users only.</p> <p>The approach listed <a href="http://top-frog.com/2010/07/01/a-simple-way-to-limit-file-downloads-to-only-logged-in-users-in-wordpress/" rel="nofollow">here</a> sounds pretty much like what I need:</p> <pre><code>Rewri...
[ { "answer_id": 144684, "author": "Chelsea Urquhart", "author_id": 34796, "author_profile": "https://wordpress.stackexchange.com/users/34796", "pm_score": 3, "selected": true, "text": "<p>You could do it like this:</p>\n\n<pre><code>location ~ \\.(mp3|m4a)$ {\n if ($http_cookie !~ \"word...
2014/05/18
[ "https://wordpress.stackexchange.com/questions/144680", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1826/" ]
I am looking for a way to restrict access to mp3 files on my site to logged in users only. The approach listed [here](http://top-frog.com/2010/07/01/a-simple-way-to-limit-file-downloads-to-only-logged-in-users-in-wordpress/) sounds pretty much like what I need: ``` RewriteEngine On RewriteBase / RewriteCond %{REQUEST...
You could do it like this: ``` location ~ \.(mp3|m4a)$ { if ($http_cookie !~ "wordpress_logged_in") { return 403; } } ``` If it is really matters that it is secured (as opposed to just not being "obviously" accessible by the general public), auth should probably also be checked since it's quite easy to send ...
144,705
<p>This is driving me crazy. Using code from the WP codex, I can add SOME buttons to the TinyMCE bar, but NOT others. For example this code:</p> <pre><code>function my_mce_buttons_2($buttons) { /** * Add in a core button that's disabled by default */ $buttons[] = 'sup'; $buttons[] = 'code'; ...
[ { "answer_id": 144711, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 4, "selected": true, "text": "<p>That is a very good question. I just tested your code locally and see the same result. A little digging r...
2014/05/18
[ "https://wordpress.stackexchange.com/questions/144705", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11023/" ]
This is driving me crazy. Using code from the WP codex, I can add SOME buttons to the TinyMCE bar, but NOT others. For example this code: ``` function my_mce_buttons_2($buttons) { /** * Add in a core button that's disabled by default */ $buttons[] = 'sup'; $buttons[] = 'code'; $button...
That is a very good question. I just tested your code locally and see the same result. A little digging reveals a twp-part problem. `wp-includes/class-wp-editor.php` is a good read for TinyMCE customizations WordPress 3.9 did update to TinyMCE 4.0 and the [TinyMCE docs](http://www.tinymce.com/wiki.php/Controls) imply...
144,735
<p>I'm trying to figure out why my text is not showing white as it should. </p> <p>I'm overriding <code>bootstrap.min.css</code> in <code>style.css</code> the <code>current-menu</code> class in Wordpress, but no success. It highlights the right tab, but the text color is not changing.</p> <p>Can anyone spot the probl...
[ { "answer_id": 144784, "author": "Robert Moszczynski", "author_id": 51816, "author_profile": "https://wordpress.stackexchange.com/users/51816", "pm_score": 3, "selected": true, "text": "<p>Ok, I solved it myself. The Drop-down list is only displayed if there is at least one public page. ...
2014/05/18
[ "https://wordpress.stackexchange.com/questions/144735", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34320/" ]
I'm trying to figure out why my text is not showing white as it should. I'm overriding `bootstrap.min.css` in `style.css` the `current-menu` class in Wordpress, but no success. It highlights the right tab, but the text color is not changing. Can anyone spot the problem? ``` .current-menu-item > a{ background-color:...
Ok, I solved it myself. The Drop-down list is only displayed if there is at least one public page. Why there is not just "There is no public page" text instead of hiding the list without a hint!? I have set every page to private, so that the list was not displayed at all. If I have made a page ​​public, I could selec...
144,736
<p>I'm having a hard time figuring out how to accomplish this (really simple) task:</p> <blockquote> <p>Get 4 random posts, but only select from the 10 most recent posts.</p> </blockquote> <p>This works great for the random part, but obviously selects from all the posts:</p> <pre><code> $query = array( ...
[ { "answer_id": 144784, "author": "Robert Moszczynski", "author_id": 51816, "author_profile": "https://wordpress.stackexchange.com/users/51816", "pm_score": 3, "selected": true, "text": "<p>Ok, I solved it myself. The Drop-down list is only displayed if there is at least one public page. ...
2014/05/18
[ "https://wordpress.stackexchange.com/questions/144736", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51820/" ]
I'm having a hard time figuring out how to accomplish this (really simple) task: > > Get 4 random posts, but only select from the 10 most recent posts. > > > This works great for the random part, but obviously selects from all the posts: ``` $query = array( 'posts_per_page' => 4, 'orderby' =>...
Ok, I solved it myself. The Drop-down list is only displayed if there is at least one public page. Why there is not just "There is no public page" text instead of hiding the list without a hint!? I have set every page to private, so that the list was not displayed at all. If I have made a page ​​public, I could selec...
144,744
<p>I'm using the Twenty Fourteen theme and think it's stupid to show full posts in the Archives section. I want just the titles to be displayed for easier navigation. Even removing the dates would be nice. (I've already done so for individual posts but the Archives section still says May 2014.) This is minor though. Th...
[ { "answer_id": 144746, "author": "renny", "author_id": 44824, "author_profile": "https://wordpress.stackexchange.com/users/44824", "pm_score": 2, "selected": false, "text": "<p>You should take a look at content.php and do a check for is_post_type_archive() on whatever you want to hide. F...
2014/05/19
[ "https://wordpress.stackexchange.com/questions/144744", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51493/" ]
I'm using the Twenty Fourteen theme and think it's stupid to show full posts in the Archives section. I want just the titles to be displayed for easier navigation. Even removing the dates would be nice. (I've already done so for individual posts but the Archives section still says May 2014.) This is minor though. The m...
You should take a look at content.php and do a check for is\_post\_type\_archive() on whatever you want to hide. For example to hide the entry-meta section, you can do the following: ``` <?php if ( !is_post_type_archive() ) { ?> <div class="entry-meta"> <?php if ( 'post' == get_post_type() ) ...
144,756
<p>Is there a way to call a dynamic sidebar by name rather than ID. </p> <p>Something like this:</p> <pre><code>$postName = get_the_category(); dynamic_sidebar($postName-&gt;category_nicename . '_sidebar') ; </code></pre>
[ { "answer_id": 144757, "author": "renny", "author_id": 44824, "author_profile": "https://wordpress.stackexchange.com/users/44824", "pm_score": 2, "selected": true, "text": "<p>You can either pass Name or ID of dynamic sidebar to dynamic_sidebar.</p>\n\n<p><a href=\"http://codex.wordpress...
2014/05/19
[ "https://wordpress.stackexchange.com/questions/144756", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/44899/" ]
Is there a way to call a dynamic sidebar by name rather than ID. Something like this: ``` $postName = get_the_category(); dynamic_sidebar($postName->category_nicename . '_sidebar') ; ```
You can either pass Name or ID of dynamic sidebar to dynamic\_sidebar. <http://codex.wordpress.org/Function_Reference/dynamic_sidebar>
144,771
<p>I need to find a simple if-condition to print the current post-depth for parents as an update notification. The following code in the functions.php is not working, it is resulting in "0" for all posts, both for parents and childs. Can anybody help out on this?</p> <pre><code>global $wpdb; global $post; $id = $post-...
[ { "answer_id": 144789, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 1, "selected": true, "text": "<p>You should wrap your condition inside the function, rather than the function inside the condition (this wil...
2014/05/19
[ "https://wordpress.stackexchange.com/questions/144771", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51307/" ]
I need to find a simple if-condition to print the current post-depth for parents as an update notification. The following code in the functions.php is not working, it is resulting in "0" for all posts, both for parents and childs. Can anybody help out on this? ``` global $wpdb; global $post; $id = $post->ID; $depth = ...
You should wrap your condition inside the function, rather than the function inside the condition (this will also prevent errors with code running too early as WordPress loads). ``` function my_admin_notice() { global $wpdb, $post; $depth = $wpdb->get_var( $wpdb->prepare( "SELECT post_parent FROM $wpd...
144,777
<p>I have a page in WordPress which includes the following valid HTML5:</p> <pre><code>&lt;div id="bookLesson"&gt; &lt;a href="lessons.php"&gt;&lt;h1&gt;Book your first lesson today&lt;/h1&gt;&lt;/a&gt; &lt;/div&gt; </code></pre> <p>When it's rendering on the page, however, it looks like this:</p> <pre><code>&lt...
[ { "answer_id": 144789, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 1, "selected": true, "text": "<p>You should wrap your condition inside the function, rather than the function inside the condition (this wil...
2014/05/19
[ "https://wordpress.stackexchange.com/questions/144777", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4109/" ]
I have a page in WordPress which includes the following valid HTML5: ``` <div id="bookLesson"> <a href="lessons.php"><h1>Book your first lesson today</h1></a> </div> ``` When it's rendering on the page, however, it looks like this: ``` <div id="bookLesson"> <a href="lessons.php"> <br /> <h1>Book you...
You should wrap your condition inside the function, rather than the function inside the condition (this will also prevent errors with code running too early as WordPress loads). ``` function my_admin_notice() { global $wpdb, $post; $depth = $wpdb->get_var( $wpdb->prepare( "SELECT post_parent FROM $wpd...
144,779
<p>I have a oswald.woff font file downloaded from some free fonts site. Using ftp i have created folder called fonts in the themes folders. (i.e /wp-content/themes/esplanade/fonts). In the fonts folder i put the oswald.woff file.</p> <pre><code>@font-face { font-family: "Oswald"; font-style: normal; font-...
[ { "answer_id": 144781, "author": "renny", "author_id": 44824, "author_profile": "https://wordpress.stackexchange.com/users/44824", "pm_score": 3, "selected": true, "text": "<p>It should be in www.mysite.com/wp-content/themes/esplanade/fonts/oswald.woff</p>\n" }, { "answer_id": 14...
2014/05/19
[ "https://wordpress.stackexchange.com/questions/144779", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/45834/" ]
I have a oswald.woff font file downloaded from some free fonts site. Using ftp i have created folder called fonts in the themes folders. (i.e /wp-content/themes/esplanade/fonts). In the fonts folder i put the oswald.woff file. ``` @font-face { font-family: "Oswald"; font-style: normal; font-weight: 400; ...
It should be in www.mysite.com/wp-content/themes/esplanade/fonts/oswald.woff
144,790
<p>I have a custom post type being output as a list. I'm trying to output some of the inline content in each li via Fancybox.</p> <p>All works so far except it only shows the first li's content. I understand that the problem is I'm calling the same ID every time in the loop.</p> <p>I used the last post <a href="https...
[ { "answer_id": 144791, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 1, "selected": false, "text": "<p>You are using the selector <code>'a[href=\"#content\"]'</code> in jQuery but the <code>href</code> attribute ...
2014/05/19
[ "https://wordpress.stackexchange.com/questions/144790", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26111/" ]
I have a custom post type being output as a list. I'm trying to output some of the inline content in each li via Fancybox. All works so far except it only shows the first li's content. I understand that the problem is I'm calling the same ID every time in the loop. I used the last post [here](https://wordpress.stacke...
You are using the selector `'a[href="#content"]'` in jQuery but the `href` attribute of the target links is `#content<?php echo $i; ?>`. Try removing `<?php echo $i; ?>` in the `href` attribute. If you need jQuery code recognise all `<a>` elements with `href` starting with the string "content" you can use the `^` modi...
144,801
<p>I looked into the difference between action and filter hooks, and as far as I understand, it is not possible to have a function, which is added to an <strong>action</strong> hook, <strong>return a (custom) value</strong>.</p> <p>My scenario:</p> <ul> <li>Upon saving a post, I <strong>try</strong> to save another p...
[ { "answer_id": 144807, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": false, "text": "<p>Correct. Action hooks do not return content, and honestly if you need an action hook to return content there...
2014/05/19
[ "https://wordpress.stackexchange.com/questions/144801", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48847/" ]
I looked into the difference between action and filter hooks, and as far as I understand, it is not possible to have a function, which is added to an **action** hook, **return a (custom) value**. My scenario: * Upon saving a post, I **try** to save another post. Therefore I use `add_action( 'save_post', 'create_anoth...
Correct. Action hooks do not return content, and honestly if you need an action hook to return content there is a pretty good chance that you are doing something wrong. However, if it turns out to be your only option the cleanest way to do it is with a static variable: ``` function action_value_grab() { static $valu...
144,812
<p>Im using a javascript/html5 script to highlight images black and white during no mouse hover, and then back to color on hover. It sorta works, although, I have to reload my page 2-3 times before it works correctly. I'm not sure how to use it, and javascript isn't really my strong suite. Since I'm using a Google CDN ...
[ { "answer_id": 144815, "author": "pdme", "author_id": 35726, "author_profile": "https://wordpress.stackexchange.com/users/35726", "pm_score": 1, "selected": false, "text": "<p>Why not use CSS? Cross-browser example here: <a href=\"http://www.karlhorky.com/2012/06/cross-browser-image-gray...
2014/05/19
[ "https://wordpress.stackexchange.com/questions/144812", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50555/" ]
Im using a javascript/html5 script to highlight images black and white during no mouse hover, and then back to color on hover. It sorta works, although, I have to reload my page 2-3 times before it works correctly. I'm not sure how to use it, and javascript isn't really my strong suite. Since I'm using a Google CDN API...
Why not use CSS? Cross-browser example here: <http://www.karlhorky.com/2012/06/cross-browser-image-grayscale-with-css.html>
144,835
<p>I would like to change the commenter links as shown in this screenshot:</p> <p><img src="https://i.stack.imgur.com/2mKaI.png" alt="screenshot"></p> <p>In <a href="https://github.com/afarber/wp-newbie/blob/master/wp-city-gender/wp-city-gender.php" rel="nofollow noreferrer">my test plugin at GitHub</a> I have first ...
[ { "answer_id": 145264, "author": "Jonathan Lafleur", "author_id": 10501, "author_profile": "https://wordpress.stackexchange.com/users/10501", "pm_score": 0, "selected": false, "text": "<p>Could you try: </p>\n\n<pre><code> $id = get_comment( get_comment_ID() )-&gt;user_id;\n</code></pre...
2014/05/19
[ "https://wordpress.stackexchange.com/questions/144835", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41372/" ]
I would like to change the commenter links as shown in this screenshot: ![screenshot](https://i.stack.imgur.com/2mKaI.png) In [my test plugin at GitHub](https://github.com/afarber/wp-newbie/blob/master/wp-city-gender/wp-city-gender.php) I have first tried the following code: ``` define('PROFILE', '<a href="/user/%s"...
You can use the [`get_comment_author_link`](https://core.trac.wordpress.org/browser/tags/3.9.1/src/wp-includes/comment-template.php#L201) hook, which is part of the [`get_comment_author_link()`](http://codex.wordpress.org/Template_Tags/get_comment_author_link) template tag, like your question already suggests. Then you...
144,836
<p>I'm creating a Wordpress site in which I wanted to use a custom taxonomy in my theme options, which I had registered using the 'init' hook. But the problem was that the 'init' hooks gets fired after the theme options (I'm using the Redux Framework plugin for the theme options). So when I used the get_categories() fu...
[ { "answer_id": 144837, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 1, "selected": false, "text": "<p>Your code without using the init hook use also a hook, but not fired from your source. A last it was fired from t...
2014/05/19
[ "https://wordpress.stackexchange.com/questions/144836", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43834/" ]
I'm creating a Wordpress site in which I wanted to use a custom taxonomy in my theme options, which I had registered using the 'init' hook. But the problem was that the 'init' hooks gets fired after the theme options (I'm using the Redux Framework plugin for the theme options). So when I used the get\_categories() func...
Your code without using the init hook use also a hook, but not fired from your source. A last it was fired from the include of the your theme, which was loaded in WordPress. It is much bad for your control. If you use a hook, then is the include from your source on your control, you choose the hook. If you will leave t...
144,870
<p>I've researched this a few times, yet my searching does not reveal much except custom code which may or may not be good WordPress practice.</p> <p>As of the latest releases (WordPress 3.9 "Smith"), <strong>has a hook been added to the plugin update process?</strong> I'm asking because its a very basic need, yet I d...
[ { "answer_id": 144873, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 5, "selected": true, "text": "<p>I don't think an action has been added. You can <a href=\"http://codex.wordpress.org/Version_3.9\">look at version ...
2014/05/20
[ "https://wordpress.stackexchange.com/questions/144870", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29565/" ]
I've researched this a few times, yet my searching does not reveal much except custom code which may or may not be good WordPress practice. As of the latest releases (WordPress 3.9 "Smith"), **has a hook been added to the plugin update process?** I'm asking because its a very basic need, yet I do not see it added to t...
I don't think an action has been added. You can [look at version details](http://codex.wordpress.org/Version_3.9) for any version and see any new actions added. The WordPress Way to run code on plugin update is what is described [here](http://make.wordpress.org/core/2010/10/27/plugin-activation-hooks-no-longer-fire-fo...
144,908
<p>My theme has the option( like any other theme I guess) to chose a predefined featured image size( thumbnail, medium ...etc). I chose the image to be thumbnail, made it 150x150 in media settings but my problem is with 480px screens. Here I want the thumbnail to be full width instead of 150px. If I add width: 100%; ru...
[ { "answer_id": 144898, "author": "Matt Royal", "author_id": 51860, "author_profile": "https://wordpress.stackexchange.com/users/51860", "pm_score": 1, "selected": true, "text": "<p>Yes this will be possible. </p>\n\n<p>I would suggest integrating your WordPress websites search with Googl...
2014/05/20
[ "https://wordpress.stackexchange.com/questions/144908", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51649/" ]
My theme has the option( like any other theme I guess) to chose a predefined featured image size( thumbnail, medium ...etc). I chose the image to be thumbnail, made it 150x150 in media settings but my problem is with 480px screens. Here I want the thumbnail to be full width instead of 150px. If I add width: 100%; rule ...
Yes this will be possible. I would suggest integrating your WordPress websites search with Google search and then you can specify the site/s (in your cause Site B) you wish to search when a users performs a search on your current site (Site A) Here is a awesome and simple tutorial a-z tutorial on how to set it all u...
144,917
<p>I've created e Custom post type with Roots theme, adding the custom script inside functions.php like</p> <pre><code>require_once locate_template('/lib/custom-post-types.php'); // Custom post types </code></pre> <p>After that in backend the list of pages is not displayed, and in frontend show this Warning:...
[ { "answer_id": 144955, "author": "albertopriore", "author_id": 9399, "author_profile": "https://wordpress.stackexchange.com/users/9399", "pm_score": 2, "selected": true, "text": "<p>Solved, it was a problem with the custom-post-types.php I was calling the type with the name <code>'post_t...
2014/05/20
[ "https://wordpress.stackexchange.com/questions/144917", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9399/" ]
I've created e Custom post type with Roots theme, adding the custom script inside functions.php like ``` require_once locate_template('/lib/custom-post-types.php'); // Custom post types ``` After that in backend the list of pages is not displayed, and in frontend show this Warning: > > Warning: strpos() e...
Solved, it was a problem with the custom-post-types.php I was calling the type with the name `'post_type'` changed that solved the issue.
144,919
<p>I am trying to enable some sort of maintenance mode for a Woocommerce site. The problem is all of the maintenance mode plugins I have seen designed for both WordPress and specifically for WooCommerce just target the entire site.</p> <p>I want to target just the shop pages.</p> <p>I have looked and all of the wooc...
[ { "answer_id": 144924, "author": "Gareth Gillman", "author_id": 33936, "author_profile": "https://wordpress.stackexchange.com/users/33936", "pm_score": 1, "selected": false, "text": "<p>Not tested but should work:</p>\n\n<p>Add the following code to it the top of your header.php, after t...
2014/05/20
[ "https://wordpress.stackexchange.com/questions/144919", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10247/" ]
I am trying to enable some sort of maintenance mode for a Woocommerce site. The problem is all of the maintenance mode plugins I have seen designed for both WordPress and specifically for WooCommerce just target the entire site. I want to target just the shop pages. I have looked and all of the woocommerce pages have...
You can add this snippet below to your themes functions file to create the message you want displayed. (For all Woocommerce conditional options, visit their codex here: <http://docs.woothemes.com/document/conditional-tags/>) ``` add_filter ('the_content', 'royal_woocommerce_maintenance'); function royal_woocommerce_ma...
144,921
<p>I have a custom post type "Product" and want to create a post category "A Product Name" automatically on creation of a new Product so that the post category (not custom post category) would have the same name as the new Product and so that all relevant posts could be linked to the custom post type. </p> <p>I was tr...
[ { "answer_id": 144939, "author": "Nicolai Grossherr", "author_id": 22534, "author_profile": "https://wordpress.stackexchange.com/users/22534", "pm_score": 3, "selected": true, "text": "<p>You are way off, if you say that <a href=\"https://codex.wordpress.org/Function_Reference/wp_publish...
2014/05/20
[ "https://wordpress.stackexchange.com/questions/144921", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34045/" ]
I have a custom post type "Product" and want to create a post category "A Product Name" automatically on creation of a new Product so that the post category (not custom post category) would have the same name as the new Product and so that all relevant posts could be linked to the custom post type. I was trying to ho...
You are way off, if you say that [`wp_publish_post()`](https://codex.wordpress.org/Function_Reference/wp_publish_post) has been renamed to `{$new_status}_{$post->post_type}`. The latter actually is a hook, while the former is a function. Where the latter is part of the former, because it's part of `wp_insert_post`. T...
144,937
<p>I have a blog with several pages in some category "projects" that are structured/named like this:</p> <ul> <li>/projects/project-2012</li> <li>/projects/project-2013</li> <li>/projects/project-2014</li> <li>/projects/project-2015</li> </ul> <p>When a user enters URLs like <em><a href="http://myblog.com/project" re...
[ { "answer_id": 144941, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 0, "selected": false, "text": "<p>Unfortunately <a href=\"http://queryposts.com/function/redirect_canonical/\" rel=\"nofollow\"><code>redirect_canoni...
2014/05/20
[ "https://wordpress.stackexchange.com/questions/144937", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51898/" ]
I have a blog with several pages in some category "projects" that are structured/named like this: * /projects/project-2012 * /projects/project-2013 * /projects/project-2014 * /projects/project-2015 When a user enters URLs like *<http://myblog.com/project>* or even *<http://myblog.com/proje>* he/she is redirected to t...
**Updated Answer (2020-10-29):** The solution has changed with Wordpress 5.5. Keeping the old answer for reference below. **Short version**: Get my pluign from here: <https://wordpress.org/plugins/disable-url-autocorrect-guessing/> **Long Version**: With Wordpress 5.5, you can control more precisely if/how the gues...
144,947
<p>I am kinda new to wordpress and I wanted to know how to make my wordpress site to show recent 4 news in this slider and again all news below:</p> <pre><code> class s_naujienos extends WP_Widget { function s_naujienos() { $widget_ops = array('classname' =&gt; 's_naujienos', 'description' =&gt; 'Nauji...
[ { "answer_id": 144954, "author": "Nicolai Grossherr", "author_id": 22534, "author_profile": "https://wordpress.stackexchange.com/users/22534", "pm_score": 1, "selected": false, "text": "<p>I'm thinking you are just missing a <a href=\"https://codex.wordpress.org/Function_Reference/wp_res...
2014/05/20
[ "https://wordpress.stackexchange.com/questions/144947", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51905/" ]
I am kinda new to wordpress and I wanted to know how to make my wordpress site to show recent 4 news in this slider and again all news below: ``` class s_naujienos extends WP_Widget { function s_naujienos() { $widget_ops = array('classname' => 's_naujienos', 'description' => 'Naujienų slideris'); ...
I'm thinking you are just missing a [`wp_reset_postdata()`](https://codex.wordpress.org/Function_Reference/wp_reset_postdata) call after you foreach loop. Take a look at [`get_posts()`](http://codex.wordpress.org/Function_Reference/get_posts), which is used by [`wp_get_recent_posts()`](http://codex.wordpress.org/Functi...
144,949
<p>I'm using a Child theme set up correctly. But I just cannot get changes in the Child theme style.css to be reflected in the site. Tried emptying the browser cache a million times and it doesn't work!</p> <p>I'v created child template files and they overide the parent ones fine.</p> <p>I have noticed in view sours...
[ { "answer_id": 144951, "author": "Gareth Gillman", "author_id": 33936, "author_profile": "https://wordpress.stackexchange.com/users/33936", "pm_score": 0, "selected": false, "text": "<p>Without seeing the site we can't help diagnose the issue but a common occurrence is the main theme css...
2014/05/20
[ "https://wordpress.stackexchange.com/questions/144949", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51904/" ]
I'm using a Child theme set up correctly. But I just cannot get changes in the Child theme style.css to be reflected in the site. Tried emptying the browser cache a million times and it doesn't work! I'v created child template files and they overide the parent ones fine. I have noticed in view sourse it puts a versio...
In twentyfourteen, try putting this in your child theme: ``` function add_require_scripts_files() { wp_enqueue_style('twentyfourteen-style', get_stylesheet_directory_uri().'/style.css', array(), '1.0.0', "all"); } add_action( 'wp_enqueue_scripts', 'add_require_scripts_files' ); ``` This will replace the ori...
144,950
<p>I believe what I'm trying to do is too complex for the standard <code>meta_query</code> parameter in <code>get_posts</code>, so I'm trying to use a custom SQL query to do the following:</p> <p>I have a game custom post that has custom fields for team1 and team2 stored as postmeta. Given team XXXX, I need to pull al...
[ { "answer_id": 144968, "author": "Blerta", "author_id": 28990, "author_profile": "https://wordpress.stackexchange.com/users/28990", "pm_score": 1, "selected": false, "text": "<p>Could you try to write this query as </p>\n\n<pre><code>SELECT DISTINCT (p.ID), p.post_title\nFROM wp_posts p\...
2014/05/20
[ "https://wordpress.stackexchange.com/questions/144950", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48623/" ]
I believe what I'm trying to do is too complex for the standard `meta_query` parameter in `get_posts`, so I'm trying to use a custom SQL query to do the following: I have a game custom post that has custom fields for team1 and team2 stored as postmeta. Given team XXXX, I need to pull all posts that have the postmeta v...
"My SQL doesn't work" questions are difficult because they are nearly untestable without having the OP's dataset, but... I think you may be making this too complicated. ``` SELECT DISTINCT (p.ID), p.post_title FROM wp_posts p JOIN wp_postmeta pm1 ON p.ID = pm1.post_id JOIN wp_postmeta pm2 ON p.ID = pm2.post_id...
144,973
<p>I am trying to write a custom post query for a specific post type in a way where only first 2 thumb/featured-image will be shown &amp; other will be just title &amp; other metadata (i.e the picture in attachment). It would be great if someone help me regarding this issue with proper guideline. Thanks in advance.</p>...
[ { "answer_id": 144976, "author": "Tired_Man", "author_id": 50055, "author_profile": "https://wordpress.stackexchange.com/users/50055", "pm_score": 1, "selected": false, "text": "<p>I would run two loops here the first one which gets the image and text and then a second loop for just the ...
2014/05/20
[ "https://wordpress.stackexchange.com/questions/144973", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51914/" ]
I am trying to write a custom post query for a specific post type in a way where only first 2 thumb/featured-image will be shown & other will be just title & other metadata (i.e the picture in attachment). It would be great if someone help me regarding this issue with proper guideline. Thanks in advance. ![attachment]...
Let's go over how this works so that next time you face this problem or a similar one, you have an idea of how to resolve it. This is expanding more on Ben's answer, the comments are in the code explaining what's happening. And you would replace "my-custom-type" with whatever your custom post type is. You can find mor...
144,989
<p>I have a WordPress plugin that at one point I need to see if a certain title exists in the database. For 2 years, this code worked fine: </p> <pre><code>$myposttitle= $wpdb-&gt;get_results( "select post_title from $wpdb-&gt;posts where post_title like '%". mysql_real_escape_string($myTitle) . "%'" ); </code>...
[ { "answer_id": 144994, "author": "gmazzap", "author_id": 35541, "author_profile": "https://wordpress.stackexchange.com/users/35541", "pm_score": 3, "selected": true, "text": "<p>When working with database in WordPress you should never use the low lever <code>mysql_*</code> or <code>mysql...
2014/05/20
[ "https://wordpress.stackexchange.com/questions/144989", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19626/" ]
I have a WordPress plugin that at one point I need to see if a certain title exists in the database. For 2 years, this code worked fine: ``` $myposttitle= $wpdb->get_results( "select post_title from $wpdb->posts where post_title like '%". mysql_real_escape_string($myTitle) . "%'" ); ``` However, with php 5.5. a...
When working with database in WordPress you should never use the low lever `mysql_*` or `mysqli_*` functions. Always use `$wpdb` methods, in your case you should use [`prepare()`](http://codex.wordpress.org/Class_Reference/wpdb#Protect_Queries_Against_SQL_Injection_Attacks): ``` $query = $wpdb->prepare( "SELECT pos...
144,995
<p>For my single.php (products.php), I try to build a navigation via which the user can switch between products based on the meta key "price". I want to put all id's of the products post type into an array and then identify the previous and next product for the navigation, based on the price meta key.</p> <p>Somehow I...
[ { "answer_id": 144997, "author": "MortalViews", "author_id": 38194, "author_profile": "https://wordpress.stackexchange.com/users/38194", "pm_score": 1, "selected": false, "text": "<p>After you use the custom query, you need to call the <code>wp_reset_postdata()</code> function, to reset ...
2014/05/20
[ "https://wordpress.stackexchange.com/questions/144995", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48132/" ]
For my single.php (products.php), I try to build a navigation via which the user can switch between products based on the meta key "price". I want to put all id's of the products post type into an array and then identify the previous and next product for the navigation, based on the price meta key. Somehow I don't man...
Save yourself a loop with `get_posts` and `'fields' => 'ids'`. ``` // Default Query function do_query($args = null) { $default_args = array( 'numberposts' => -1, 'posts_per_page' => -1, 'post_status' => 'publish', 'fields' => 'ids', ); if (null !== $args && !empty($args))...
145,007
<p>I'm not crazy familiar with WPDB or SQL in general but I have a custom table for my project and I'm trying to assign some metadata to it. What I'd "like" to happen is if a row exists, update it and if not insert it. I've read both Insert and Update in the WPDB Codex but neither really went into an "either or" situat...
[ { "answer_id": 145012, "author": "felipelavinz", "author_id": 16714, "author_profile": "https://wordpress.stackexchange.com/users/16714", "pm_score": -1, "selected": false, "text": "<p>You should check if the row exists first. </p>\n\n<p>Most likely you'll want to try to get the ID or pr...
2014/05/20
[ "https://wordpress.stackexchange.com/questions/145007", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7355/" ]
I'm not crazy familiar with WPDB or SQL in general but I have a custom table for my project and I'm trying to assign some metadata to it. What I'd "like" to happen is if a row exists, update it and if not insert it. I've read both Insert and Update in the WPDB Codex but neither really went into an "either or" situation...
First, you are using `prepare` incorrectly. You seem to have `$wpdb->update`'s arguments wrapped in `$wpdb->prepare` like that. That won't work. In effect, you are passing `update` a single argument-- the output of `prepare`. Try something simple like the following and you will see why that won't work: ``` $post_id = ...