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
97,908
<p>I'm trying to figure out some kind of mechanism to load plugins on demand, depending on the page url, to improve performance.</p> <p>My primary concern is that I have some admin-ajax.php calls that are recurring while the user is active on the page. I tried profiling these calls, and discovered that the majority of...
[ { "answer_id": 97931, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 4, "selected": true, "text": "<p>Filter <code>option_active_plugins</code>. You can change the result of <code>get_option()</code> here without actually...
2013/05/01
[ "https://wordpress.stackexchange.com/questions/97908", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26808/" ]
I'm trying to figure out some kind of mechanism to load plugins on demand, depending on the page url, to improve performance. My primary concern is that I have some admin-ajax.php calls that are recurring while the user is active on the page. I tried profiling these calls, and discovered that the majority of plugins l...
Filter `option_active_plugins`. You can change the result of `get_option()` here without actually changing the database. ``` if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) add_filter( 'option_active_plugins', 'disable_plugins_temporary' ); function disable_plugins_temporary( $plugins ) { // unset plugins you do...
97,968
<p>Installed <a href="http://www.nsp-code.com/premium-plugins/wordpress-plugins/advanced-post-types-order/" rel="nofollow">a plugin</a> that allows the re-ordering of posts from any post type / category / tag using a drag/drop interface.</p> <p>After some time of using, my post order went haywire and new posts began t...
[ { "answer_id": 97969, "author": "Manny Fleurmond", "author_id": 2234, "author_profile": "https://wordpress.stackexchange.com/users/2234", "pm_score": 3, "selected": true, "text": "<p>This piece of mySQL code should do the trick. Go into PHPmyAdmin, click the SQL tab and paste this code:...
2013/05/01
[ "https://wordpress.stackexchange.com/questions/97968", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18228/" ]
Installed [a plugin](http://www.nsp-code.com/premium-plugins/wordpress-plugins/advanced-post-types-order/) that allows the re-ordering of posts from any post type / category / tag using a drag/drop interface. After some time of using, my post order went haywire and new posts began to appear in a jumbled order. The plu...
This piece of mySQL code should do the trick. Go into PHPmyAdmin, click the SQL tab and paste this code: ``` UPDATE wp_posts SET menu_order = 0 WHERE post_type = 'my_post_type'; ``` This should set `menu_order` for all posts of the post type of your choice to 0.
97,993
<p>I have a wordpress setup that I use for clients with around 30 or so child themes that they can choose from. Each child theme has it's own functions.php file currently. Is it possible to setup just one child functions.php and call it from all the separate child themes? My reason for wanting this functionality is ...
[ { "answer_id": 97994, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 4, "selected": true, "text": "<p>Well, I'd say that you need a custom plugin. All the rationale is in this Q&amp;A:</p>\n\n<p><a href=\"https:...
2013/05/01
[ "https://wordpress.stackexchange.com/questions/97993", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15114/" ]
I have a wordpress setup that I use for clients with around 30 or so child themes that they can choose from. Each child theme has it's own functions.php file currently. Is it possible to setup just one child functions.php and call it from all the separate child themes? My reason for wanting this functionality is I find...
Well, I'd say that you need a custom plugin. All the rationale is in this Q&A: [Where to put my code: plugin or functions.php?](https://wordpress.stackexchange.com/q/73031/12615) Also related: * [Where do I put the code snippets I found here or somewhere else on the web?](https://wordpress.stackexchange.com/q/72160/...
98,006
<p>I have a custom post type called 'portcat' and I want to display the results of only one portcat category ('games' - which has an ID of '3') on my page. The below code displays all of the categories and I'm not sure what I need to add to make it display only the 'games' category?</p> <pre><code>&lt;h4 class="nomar"...
[ { "answer_id": 98012, "author": "tomca32", "author_id": 32242, "author_profile": "https://wordpress.stackexchange.com/users/32242", "pm_score": 0, "selected": false, "text": "<p>This is the query you're looking for:</p>\n\n<pre><code>$args = array(\n'post_type' =&gt; 'port',\n'paged' =&g...
2013/05/02
[ "https://wordpress.stackexchange.com/questions/98006", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31114/" ]
I have a custom post type called 'portcat' and I want to display the results of only one portcat category ('games' - which has an ID of '3') on my page. The below code displays all of the categories and I'm not sure what I need to add to make it display only the 'games' category? ``` <h4 class="nomar"><?php echo the_t...
Something like this should work but you haven't stated where you want to display the CPT pages for games. ``` function display_games_archive( $query ) { if ( !is_admin() || $query->is_main_query() && is_post_type_archive( 'portcat' ) ) { $query->set( 'category__in', 'games' ); return; } } add_action( 'pr...
98,024
<p>I was curious if was possible to display related posts by multiple tags.</p> <p>The site I am working on has about 5 tags per post. Most posts have 1 or 2 tags in common. The related posts I'd like to show have 3-5 tags in common. </p> <p>So, I'd like the related posts to function by looking for posts with the mos...
[ { "answer_id": 108930, "author": "Dero", "author_id": 36190, "author_profile": "https://wordpress.stackexchange.com/users/36190", "pm_score": 0, "selected": false, "text": "<p>I don't think <code>query_posts()</code> or <code>new WP_Query()</code> will do any good here. You need to query...
2013/05/02
[ "https://wordpress.stackexchange.com/questions/98024", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32290/" ]
I was curious if was possible to display related posts by multiple tags. The site I am working on has about 5 tags per post. Most posts have 1 or 2 tags in common. The related posts I'd like to show have 3-5 tags in common. So, I'd like the related posts to function by looking for posts with the most number of tags ...
I had the same idea and wrote a small little plugin to help me do this. ``` function get_pew_related_data($args, $post_id, $related_id) { global $post, $wpdb; $post_id = intval( $post_id ); if( !$post_id && $post->ID ) { $post_id = $post->ID; } if( !$post_id ) { return false; ...
98,032
<p>I'm trying to work which plugin is triggering wp-cron. I know about the code: <a href="http://codex.wordpress.org/Function_Reference/wp_get_schedules">http://codex.wordpress.org/Function_Reference/wp_get_schedules</a> , but I'd prefer to do something in the sql backend rather than write a plugin.</p>
[ { "answer_id": 98076, "author": "montrealist", "author_id": 8105, "author_profile": "https://wordpress.stackexchange.com/users/8105", "pm_score": 6, "selected": true, "text": "<p>Why don't you just create a cron job, make a database dump and look where the info about the cron job is kept...
2013/05/02
[ "https://wordpress.stackexchange.com/questions/98032", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9958/" ]
I'm trying to work which plugin is triggering wp-cron. I know about the code: <http://codex.wordpress.org/Function_Reference/wp_get_schedules> , but I'd prefer to do something in the sql backend rather than write a plugin.
Why don't you just create a cron job, make a database dump and look where the info about the cron job is kept? That's what I did. As suspected, WordPress 3.5.1 keeps its cron jobs in the `{wp}_options` table under the name `'cron'`. ``` SELECT * FROM `wp_options` WHERE `option_name` LIKE '%cron%' ``` Or through func...
98,042
<p>I am trying to make a simple media manager on the front end of my posts, as my site will have many authors. I want to give them the ability to delete any picture attachments that they have uploaded to their posts ( without having access to the media manager, because I want this to be mobile compatible). </p> <p>Fro...
[ { "answer_id": 98086, "author": "Santoro", "author_id": 16902, "author_profile": "https://wordpress.stackexchange.com/users/16902", "pm_score": 3, "selected": true, "text": "<p>You can do it via ajax, first, let's change your current function to this:</p>\n\n<pre><code>&lt;?php \n\n$args...
2013/05/02
[ "https://wordpress.stackexchange.com/questions/98042", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28123/" ]
I am trying to make a simple media manager on the front end of my posts, as my site will have many authors. I want to give them the ability to delete any picture attachments that they have uploaded to their posts ( without having access to the media manager, because I want this to be mobile compatible). From my resea...
You can do it via ajax, first, let's change your current function to this: ``` <?php $args = array( 'order' => 'ASC', 'orderby' => 'menu_order', 'post_type' => 'attachment', 'post_parent' => $post->ID, 'post_mime_type' => 'image', ...
98,045
<p>Looking for some help on something that has me really contemplating not using blockquotes for the moment!</p> <p>I have this code:</p> <pre><code>&lt;?php $show_after_p = 1; $content = apply_filters( 'the_content', get_the_content() ); if(substr_count($content, '&lt;p&gt;') &gt; $show_after_p) { $c...
[ { "answer_id": 98047, "author": "Santoro", "author_id": 16902, "author_profile": "https://wordpress.stackexchange.com/users/16902", "pm_score": 0, "selected": false, "text": "<p>Maybe you can use a simple preg_replace, but you have to remove spaces around P in this example</p>\n\n<p>$res...
2013/05/02
[ "https://wordpress.stackexchange.com/questions/98045", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17411/" ]
Looking for some help on something that has me really contemplating not using blockquotes for the moment! I have this code: ``` <?php $show_after_p = 1; $content = apply_filters( 'the_content', get_the_content() ); if(substr_count($content, '<p>') > $show_after_p) { $contents = explode('<p>', $content...
Manipulating HTML with regular expressions is not a good idea. I suggest you use [DOMDocument](http://www.php.net/manual/en/book.dom.php): ``` // input $html = apply_filters('the_content', get_the_content()); $dom = new \DomDocument(); $dom->loadHtml($html); $blockquotes = $dom->getElementsByTagName('blockquote'); f...
98,055
<p>I'm searching for a solution where the user can define some sidebar widgets for himself (only text and images). The user should have the possibility to choose a different sidebar for a different page.</p> <p>WidgetLogic and so on only allow the configuration on which page a sidebar widget should be shown (also a st...
[ { "answer_id": 98047, "author": "Santoro", "author_id": 16902, "author_profile": "https://wordpress.stackexchange.com/users/16902", "pm_score": 0, "selected": false, "text": "<p>Maybe you can use a simple preg_replace, but you have to remove spaces around P in this example</p>\n\n<p>$res...
2013/05/02
[ "https://wordpress.stackexchange.com/questions/98055", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13921/" ]
I'm searching for a solution where the user can define some sidebar widgets for himself (only text and images). The user should have the possibility to choose a different sidebar for a different page. WidgetLogic and so on only allow the configuration on which page a sidebar widget should be shown (also a standard use...
Manipulating HTML with regular expressions is not a good idea. I suggest you use [DOMDocument](http://www.php.net/manual/en/book.dom.php): ``` // input $html = apply_filters('the_content', get_the_content()); $dom = new \DomDocument(); $dom->loadHtml($html); $blockquotes = $dom->getElementsByTagName('blockquote'); f...
98,066
<p>I'd like to change where the 'Howdy' link gets you when you click on it.</p> <p>I have a website with buddypress and instead of getting users to their profile page I want to get them to their 'Activity' tab.</p> <p>How can I change the link?</p> <p>Thanks, Kat</p>
[ { "answer_id": 98071, "author": "t31os", "author_id": 31073, "author_profile": "https://wordpress.stackexchange.com/users/31073", "pm_score": 4, "selected": true, "text": "<p>It's not well documented, but the <code>add_node</code> and <code>add_menu</code> methods of the <code>WP_Admin_B...
2013/05/02
[ "https://wordpress.stackexchange.com/questions/98066", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25277/" ]
I'd like to change where the 'Howdy' link gets you when you click on it. I have a website with buddypress and instead of getting users to their profile page I want to get them to their 'Activity' tab. How can I change the link? Thanks, Kat
It's not well documented, but the `add_node` and `add_menu` methods of the `WP_Admin_Bar` class can be used not only to create new menu or nodes, but also to update an existing menu or node. So i went ahead and tracked down the code that WordPress initially uses to create that item in the admin bar, replicated it, the...
98,085
<p>I am using the following code for a navigation bar on a WordPress website:</p> <pre><code>&lt;?php wp_list_pages("title_li="); ?&gt; </code></pre> <p>Which currently spits out some links that look like:</p> <pre><code>&lt;a href="http://yoururl.com/?page_id=123"&gt;News&lt;/a&gt; </code></pre> <p>What I'd like t...
[ { "answer_id": 98094, "author": "Santoro", "author_id": 16902, "author_profile": "https://wordpress.stackexchange.com/users/16902", "pm_score": 0, "selected": false, "text": "<p>Well, you can do it with jQuery, if your links are inside a div with given ID of 'menu', so you could write:</...
2013/05/02
[ "https://wordpress.stackexchange.com/questions/98085", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9820/" ]
I am using the following code for a navigation bar on a WordPress website: ``` <?php wp_list_pages("title_li="); ?> ``` Which currently spits out some links that look like: ``` <a href="http://yoururl.com/?page_id=123">News</a> ``` What I'd like to do is have the ability to add an id to a link so that it looks li...
I wasn't able to find something that would add an id, but I did find something that would give me a class...this way I can target the class using jQuery. The default id's and classes are ok, but the solution I found is much better because no matter which website you apply it to it will work, I don't ever have to go bac...
98,088
<p>I try to keep user subscription in a metadata var. The function is called by AJAX. Ahe AJAX is called but the metadata does not seem updated on frontend.</p> <p>Here is the code:</p> <p>jQuery</p> <pre><code>&lt;script type="text/javascript"&gt; jQuery(document).ready(function($) { $('#tags_list a').c...
[ { "answer_id": 119426, "author": "indextwo", "author_id": 17826, "author_profile": "https://wordpress.stackexchange.com/users/17826", "pm_score": 0, "selected": false, "text": "<p>I was trying this exact method myself and was curious as to why your code wouldn't work. I changed two thing...
2013/05/02
[ "https://wordpress.stackexchange.com/questions/98088", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/395/" ]
I try to keep user subscription in a metadata var. The function is called by AJAX. Ahe AJAX is called but the metadata does not seem updated on frontend. Here is the code: jQuery ``` <script type="text/javascript"> jQuery(document).ready(function($) { $('#tags_list a').click(function(){ myid ...
First You can get rid of nasty globals in your AJAX call. I'm not sure what the `$st` variable that you were output is all about so I've excluded, but you can include as you wish - ``` add_action('wp_ajax_change_subscription', 'change_subscription'); function change_subscription(){ if(!empty($_POST['term_id']) &&...
98,102
<p>So, I've run into what looks like a WP RAM usage problem and am looking for a solution.</p> <p>The only place I'm really having this problem on my site is with a Site Map page that I'm trying to populate, but a solution to this problem could be universally applied and save on RAM usage across an entire site.</p> <...
[ { "answer_id": 98105, "author": "NW Tech", "author_id": 5295, "author_profile": "https://wordpress.stackexchange.com/users/5295", "pm_score": 2, "selected": false, "text": "<p>You might try adding this to your array:</p>\n\n<pre><code>'nopaging' =&gt; true,\n'no_found_rows' =&gt; true,\n...
2013/05/02
[ "https://wordpress.stackexchange.com/questions/98102", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31611/" ]
So, I've run into what looks like a WP RAM usage problem and am looking for a solution. The only place I'm really having this problem on my site is with a Site Map page that I'm trying to populate, but a solution to this problem could be universally applied and save on RAM usage across an entire site. Essentially, th...
You can try a trick with querying post data directly and setting `filter` field of post objects to `sample` before passing it to `get_permalink()` to reduce memory usage. See [get\_permalink memory usage issue](http://yoast.com/get_permalink-memory-usage-issues/) for detailed reasoning behind it.
98,109
<p>I currently enque jQuery like so - how do I move this to the footer instead?</p> <pre><code>// Enque: jQuery if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11); function my_jquery_enqueue() { wp_deregister_script('jquery'); wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT']...
[ { "answer_id": 98105, "author": "NW Tech", "author_id": 5295, "author_profile": "https://wordpress.stackexchange.com/users/5295", "pm_score": 2, "selected": false, "text": "<p>You might try adding this to your array:</p>\n\n<pre><code>'nopaging' =&gt; true,\n'no_found_rows' =&gt; true,\n...
2013/05/02
[ "https://wordpress.stackexchange.com/questions/98109", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5205/" ]
I currently enque jQuery like so - how do I move this to the footer instead? ``` // Enque: jQuery if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11); function my_jquery_enqueue() { wp_deregister_script('jquery'); wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" ...
You can try a trick with querying post data directly and setting `filter` field of post objects to `sample` before passing it to `get_permalink()` to reduce memory usage. See [get\_permalink memory usage issue](http://yoast.com/get_permalink-memory-usage-issues/) for detailed reasoning behind it.
98,116
<p>The code below produces a sub-menu of child categories of the currently active parent category. This code also produces the child categories of the top parent category while viewing child categories and posts in those categories. The <code>.current-cat</code> CSS class is applied to the active child categories.</p...
[ { "answer_id": 98117, "author": "gdaniel", "author_id": 30984, "author_profile": "https://wordpress.stackexchange.com/users/30984", "pm_score": 0, "selected": false, "text": "<p>From wordpress Codex:</p>\n\n<p>current_category \n(integer) Allows you to force the \"current-cat\" to appear...
2013/05/02
[ "https://wordpress.stackexchange.com/questions/98116", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5205/" ]
The code below produces a sub-menu of child categories of the currently active parent category. This code also produces the child categories of the top parent category while viewing child categories and posts in those categories. The `.current-cat` CSS class is applied to the active child categories. This is the most ...
very similar approach to the answer by @AndrettiMilas: ``` add_filter('wp_list_categories','style_current_cat_single_post'); // filter to add the .current-cat class to categories list in single post function style_current_cat_single_post($output) { if( is_single() ) : global $post; foreach ( get_th...
98,121
<p>Is it possible to display a featured image on a news page that uses index.php? </p> <p>I'm currently using wp_query to display posts from a specific category on the news page. Each post has his own featured image which isn't displayed on the index/news page but only for the post itself.</p> <p>If i place <code>&lt...
[ { "answer_id": 98124, "author": "21zna9", "author_id": 8902, "author_profile": "https://wordpress.stackexchange.com/users/8902", "pm_score": 0, "selected": false, "text": "<p>In the query, you should use <a href=\"http://codex.wordpress.org/Function_Reference/the_post_thumbnail\" rel=\"n...
2013/05/02
[ "https://wordpress.stackexchange.com/questions/98121", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28103/" ]
Is it possible to display a featured image on a news page that uses index.php? I'm currently using wp\_query to display posts from a specific category on the news page. Each post has his own featured image which isn't displayed on the index/news page but only for the post itself. If i place `<?php the_post_thumbnail...
If I am reading your question correctly, the problem is that when you set a page so that it has a an archive Loop on it `$wp_query` and the `$posts` variable are set to for the index Loop and not for the page the are on. To get information about that page you need [`get_queried_object`](http://codex.wordpress.org/Funct...
98,126
<p>I have a query that loops through <code>&lt;li&gt;</code>'s and displays the number of <code>&lt;li&gt;</code>'s I have. Is there a way I can make the loop pull 2 <code>&lt;li&gt;</code>'s at a time rather than one?</p> <pre><code>// 5 list items &lt;ul&gt; &lt;?php while(has_posts()): the_post(); ?&gt; &lt;li...
[ { "answer_id": 98129, "author": "Sagive", "author_id": 7990, "author_profile": "https://wordpress.stackexchange.com/users/7990", "pm_score": 3, "selected": true, "text": "<p>Easy using <a href=\"https://codex.wordpress.org/Class_Reference/WP_Query\" rel=\"nofollow\">WP query</a> (get to ...
2013/05/02
[ "https://wordpress.stackexchange.com/questions/98126", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13169/" ]
I have a query that loops through `<li>`'s and displays the number of `<li>`'s I have. Is there a way I can make the loop pull 2 `<li>`'s at a time rather than one? ``` // 5 list items <ul> <?php while(has_posts()): the_post(); ?> <li> <div class="slide"><?php the_content(); ?></div> </li> <?php endwhi...
Easy using [WP query](https://codex.wordpress.org/Class_Reference/WP_Query) (get to know it...) ``` <ul> <?php $recentPosts = new WP_Query(); $recentPosts->query('showposts=2'); // SET AMOUNT HERE ?> <?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?> <li><div cl...
98,140
<p>So I'm using WordPress in a 'themeless' manner, i.e. not using a "blog" template. My site files are in the root directory (not in the theme folder), and WordPressis installed in its own <code>/wordpress/</code> directory. The only thing my theme exists for is customization of the back-end, including re-branding and ...
[ { "answer_id": 98129, "author": "Sagive", "author_id": 7990, "author_profile": "https://wordpress.stackexchange.com/users/7990", "pm_score": 3, "selected": true, "text": "<p>Easy using <a href=\"https://codex.wordpress.org/Class_Reference/WP_Query\" rel=\"nofollow\">WP query</a> (get to ...
2013/05/02
[ "https://wordpress.stackexchange.com/questions/98140", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32329/" ]
So I'm using WordPress in a 'themeless' manner, i.e. not using a "blog" template. My site files are in the root directory (not in the theme folder), and WordPressis installed in its own `/wordpress/` directory. The only thing my theme exists for is customization of the back-end, including re-branding and custom post ty...
Easy using [WP query](https://codex.wordpress.org/Class_Reference/WP_Query) (get to know it...) ``` <ul> <?php $recentPosts = new WP_Query(); $recentPosts->query('showposts=2'); // SET AMOUNT HERE ?> <?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?> <li><div cl...
98,141
<p>Thanks in advance for any assistance. </p> <p>I have a simple 4 page portfolio site I'm trying to build for myself. The pages consist of: Home Page, Print Design, Digital, and Identity.</p> <p>I have created a custom post type called "portfolio" with categories: "Print Design", "Digital", and "Identity".</p> <p>W...
[ { "answer_id": 98145, "author": "vancoder", "author_id": 26778, "author_profile": "https://wordpress.stackexchange.com/users/26778", "pm_score": 1, "selected": false, "text": "<p>Lifted straight from <a href=\"http://codex.wordpress.org/Function_Reference/in_category\" rel=\"nofollow\">t...
2013/05/02
[ "https://wordpress.stackexchange.com/questions/98141", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31423/" ]
Thanks in advance for any assistance. I have a simple 4 page portfolio site I'm trying to build for myself. The pages consist of: Home Page, Print Design, Digital, and Identity. I have created a custom post type called "portfolio" with categories: "Print Design", "Digital", and "Identity". When first visiting the s...
Lifted straight from [the codex](http://codex.wordpress.org/Function_Reference/in_category): ``` <?php if ( in_category( 'pachyderms' )) { // They have long trunks... } elseif ( in_category( array( 'Tropical Birds', 'small-mammals' ) )) { // They are warm-blooded... } else { // & c. } ?> ``` So, just us...
98,156
<p>I really like the <code>WP_Image_Editor</code> class. I wanted to use it for some custom functionality I'm making, but I was wondering - Watermarking images - is there a way that I could use the objects created by <code>WP_Image_Editor</code> to merge an image with a watermark? I cannot figure out any obvious way.</...
[ { "answer_id": 219378, "author": "David", "author_id": 31323, "author_profile": "https://wordpress.stackexchange.com/users/31323", "pm_score": 2, "selected": false, "text": "<p>If you really want to use these classes the only way would be to extend both existing implementations <code>Wp_...
2013/05/03
[ "https://wordpress.stackexchange.com/questions/98156", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29565/" ]
I really like the `WP_Image_Editor` class. I wanted to use it for some custom functionality I'm making, but I was wondering - Watermarking images - is there a way that I could use the objects created by `WP_Image_Editor` to merge an image with a watermark? I cannot figure out any obvious way.
If you really want to use these classes the only way would be to extend both existing implementations `Wp_Image_Editor_Imagick` and `Wp_Image_Editor_GD`. Here's an approach for the `Wp_Image_Editor_GD`: ``` namespace WPSE98156; use Wp_Image_Editor_Gd, Wp_Error; class WatermarkImageEditor extends Wp_Image_E...
98,175
<p>I'm trying to take a list of tags and list them on the page but without linking to their archive page. </p> <p>At the moment I'm doing this:</p> <pre><code>&lt;?php global $wp_query; $postid = $wp_query-&gt;post-&gt;ID; echo get_the_term_list( $post-&gt;ID, 'visits', 'Visits ', ', ', ' ' ); wp_reset_query(); ?&gt;...
[ { "answer_id": 98178, "author": "Praveen Shekhawat", "author_id": 32247, "author_profile": "https://wordpress.stackexchange.com/users/32247", "pm_score": 0, "selected": false, "text": "<p>List all the terms in a custom taxonomy, without a link:</p>\n\n<pre><code>$terms = get_terms(\"my_t...
2013/05/03
[ "https://wordpress.stackexchange.com/questions/98175", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16726/" ]
I'm trying to take a list of tags and list them on the page but without linking to their archive page. At the moment I'm doing this: ``` <?php global $wp_query; $postid = $wp_query->post->ID; echo get_the_term_list( $post->ID, 'visits', 'Visits ', ', ', ' ' ); wp_reset_query(); ?> ``` Thanks
You can use [`get_the_terms()`](http://codex.wordpress.org/Function_Reference/get_the_terms). I've adapted the following from an example on that page: ``` $terms = get_the_terms( $post->ID, 'visits' ); if ( $terms && ! is_wp_error( $terms ) ) : $visits_name = array(); foreach ( $terms as $term ) { ...
98,187
<p>I have been looking for a long time, but I could not find a solution. I'm not a coder. Please help me. Here is my wp_query code;</p> <pre><code>$my_query = new WP_Query('category_name=animals&amp;showposts=10'); while ($my_query-&gt;have_posts()) : $my_query-&gt;the_post(); $do_not_duplicate = $post-&gt;ID...
[ { "answer_id": 98188, "author": "Balas", "author_id": 17849, "author_profile": "https://wordpress.stackexchange.com/users/17849", "pm_score": 1, "selected": false, "text": "<pre><code>$category = get_cat_ID('animals');\n\n// The Query\n\n$args = array('post__in' =&gt; get_option( 'sticky...
2013/05/03
[ "https://wordpress.stackexchange.com/questions/98187", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32344/" ]
I have been looking for a long time, but I could not find a solution. I'm not a coder. Please help me. Here is my wp\_query code; ``` $my_query = new WP_Query('category_name=animals&showposts=10'); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; ?> <li><a href="<?p...
It is not entirely clear what you are trying to do but sticky posts should be at the top-- that is, the first posts displayed-- already unless you have made an effort to prevent that. That is the default. I just tested this with your query, changing only the category ID to something that exists on my server. To preven...
98,197
<p>In my functions.php I have the following code:</p> <pre><code>add_action( 'admin_menu', 'jp_create_admin_pages' ); function jp_create_admin_pages() { add_menu_page( 'Members', 'Members', 'manage_options', 'members', 'admin-members.php'); } </code></pre> <p>In the same f...
[ { "answer_id": 98202, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 3, "selected": true, "text": "<p>You can’t. Create a function that loads that file:</p>\n\n<pre><code>function load_admin_page_file()\n{\n require 'a...
2013/05/03
[ "https://wordpress.stackexchange.com/questions/98197", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24655/" ]
In my functions.php I have the following code: ``` add_action( 'admin_menu', 'jp_create_admin_pages' ); function jp_create_admin_pages() { add_menu_page( 'Members', 'Members', 'manage_options', 'members', 'admin-members.php'); } ``` In the same folder, I have another file...
You can’t. Create a function that loads that file: ``` function load_admin_page_file() { require 'admin-members.php'; } ``` Then use that function name as callback argument. In PHP 5.3 you can use a lambda: ``` add_menu_page( 'Members', 'Members', 'manage_options', 'members', function() { r...
98,211
<p>I'm quite new to wordpress. I'm trying to build a tableview within a wordpress page. Therfore I need a custom SQL Query to my MySQL Database.</p> <ol> <li>Query data from my MySQL Database</li> <li>Get the result somehow in a HTML format in order to display it in a table view within a wordpress page.</li> </ol> <p...
[ { "answer_id": 98225, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 3, "selected": false, "text": "<p>The <code>wpdb</code> object can be used to <a href=\"http://codex.wordpress.org/Class_Reference/wpdb#Run_Any_Query_o...
2013/05/03
[ "https://wordpress.stackexchange.com/questions/98211", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32354/" ]
I'm quite new to wordpress. I'm trying to build a tableview within a wordpress page. Therfore I need a custom SQL Query to my MySQL Database. 1. Query data from my MySQL Database 2. Get the result somehow in a HTML format in order to display it in a table view within a wordpress page. My question is: How can I use th...
The `wpdb` object can be used to [run arbitrary queries](http://codex.wordpress.org/Class_Reference/wpdb#Run_Any_Query_on_the_Database) against the WordPress database. Let's say you want to list the most recent 4 posts: ``` $results = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE `post_type`='post' LIMIT 4" );...
98,219
<p>I'm trying to replace a word on every page for example "Denver" with a word from a URL string, so I'll have like <code>?city=Atlanta</code> in the URL. So I was thinking of using PHP's GET to just get the city from the URL string and <a href="http://php.net/manual/en/function.str-replace.php" rel="nofollow"><code>s...
[ { "answer_id": 98225, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 3, "selected": false, "text": "<p>The <code>wpdb</code> object can be used to <a href=\"http://codex.wordpress.org/Class_Reference/wpdb#Run_Any_Query_o...
2013/05/03
[ "https://wordpress.stackexchange.com/questions/98219", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19513/" ]
I'm trying to replace a word on every page for example "Denver" with a word from a URL string, so I'll have like `?city=Atlanta` in the URL. So I was thinking of using PHP's GET to just get the city from the URL string and [`str_replace`](http://php.net/manual/en/function.str-replace.php) to replace it, but which actio...
The `wpdb` object can be used to [run arbitrary queries](http://codex.wordpress.org/Class_Reference/wpdb#Run_Any_Query_on_the_Database) against the WordPress database. Let's say you want to list the most recent 4 posts: ``` $results = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE `post_type`='post' LIMIT 4" );...
98,226
<p>I am creating a submenu with the following code:</p> <pre><code>add_action( 'admin_menu', 'jp_create_admin_pages' ); function jp_create_admin_pages() { add_menu_page( 'Members', 'Members', 'manage_options', 'members', 'jp_handle_admin_members'); add_submenu_page( ...
[ { "answer_id": 98231, "author": "ckpepper02", "author_id": 18404, "author_profile": "https://wordpress.stackexchange.com/users/18404", "pm_score": 1, "selected": false, "text": "<p>Have you tried changing the <code>Menu title</code> to <strong>'All Membership Types'</strong>? </p>\n\n<pr...
2013/05/03
[ "https://wordpress.stackexchange.com/questions/98226", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24655/" ]
I am creating a submenu with the following code: ``` add_action( 'admin_menu', 'jp_create_admin_pages' ); function jp_create_admin_pages() { add_menu_page( 'Members', 'Members', 'manage_options', 'members', 'jp_handle_admin_members'); add_submenu_page( 'members...
The first menu item typically is the parent item and shares the name with that item, you can however manually update the entry directly in the `$submenu` variable, like so.. ``` add_action( 'admin_menu', 'jp_create_admin_pages' ); function jp_create_admin_pages() { global $submenu; add_menu_page('Members','Me...
98,244
<p>What I would like to have is the sentence "Entre em contacto connosco para saber preços Aqui" just in product page, not in shop page. Please take a look in this page: <a href="http://www.kepaweleurope.com/shop/soutien-mamoplastia-85/" rel="nofollow">http://www.kepaweleurope.com/shop/soutien-mamoplastia-85/</a></p> ...
[ { "answer_id": 98251, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 3, "selected": false, "text": "<p>The short description template is /templates/single-product/short-description.php :</p>\n\n<pre><code>&lt...
2013/05/03
[ "https://wordpress.stackexchange.com/questions/98244", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32367/" ]
What I would like to have is the sentence "Entre em contacto connosco para saber preços Aqui" just in product page, not in shop page. Please take a look in this page: <http://www.kepaweleurope.com/shop/soutien-mamoplastia-85/> Does anybody can help me? Thanks in advance Miguel
The short description template is /templates/single-product/short-description.php : ``` <?php /** * Single product short description * * @author WooThemes * @package WooCommerce/Templates * @version 1.6.4 */ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly global $post; if ( ! $po...
98,247
<p>I'm having trouble getting post by term in a custom taxonomy I have set up. The catch is this is multisite and I'm getting this data from another blog on the network where the taxonomy is registered. The code I have works fine on the blog with which the taxonomy is registered. However when I try the same code on the...
[ { "answer_id": 98260, "author": "Cole", "author_id": 2130, "author_profile": "https://wordpress.stackexchange.com/users/2130", "pm_score": 0, "selected": false, "text": "<p>This is a long shot and assumes all your taxonomies are setup and being queried correctly. </p>\n\n<p>But since you...
2013/05/03
[ "https://wordpress.stackexchange.com/questions/98247", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12068/" ]
I'm having trouble getting post by term in a custom taxonomy I have set up. The catch is this is multisite and I'm getting this data from another blog on the network where the taxonomy is registered. The code I have works fine on the blog with which the taxonomy is registered. However when I try the same code on the ot...
Solution (or at least in part) The problem is switch\_to\_blog doesn't give you access to everything in another blog on the network including taxonomies, tags, things in your functions.php, although don't quote me 100% on that. Therefore the taxonomy wasn't registered in the "switched to" blog. My solution (at least f...
98,269
<p>How can I add pre-defined options to the "add new" custom field dropdown?</p> <p><img src="https://i.stack.imgur.com/WhvMS.png" alt="enter image description here"></p> <p>Here's two examples of automatically adding and showing new custom fields:</p> <ol> <li><a href="http://help.cazue.com/wordpress-adding-default...
[ { "answer_id": 98270, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 4, "selected": true, "text": "<p>You cannot do that with pure PHP, because the fields are fetched from existing fields, and there is no hook. But you ca...
2013/05/04
[ "https://wordpress.stackexchange.com/questions/98269", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32387/" ]
How can I add pre-defined options to the "add new" custom field dropdown? ![enter image description here](https://i.stack.imgur.com/WhvMS.png) Here's two examples of automatically adding and showing new custom fields: 1. [WordPress: Adding Default Custom Fields on New Posts](http://help.cazue.com/wordpress-adding-de...
You cannot do that with pure PHP, because the fields are fetched from existing fields, and there is no hook. But you can use JavaScript, check if the post type supports custom fields and the field does not exist already – and insert it: ``` <?php # -*- coding: utf-8 -*- /* Plugin Name: Extend custom fields */ add_act...
98,274
<p>I'm trying to find a way of disabling the selection of the parent category within Wordpress 3.5.1 (post editor screen) <strong>only</strong> when that parent category contains child categories.</p> <p>My structure:</p> <ul> <li>Category 1 (no children, allow users to post, keep selection option)</li> <li>Galleries...
[ { "answer_id": 98686, "author": "Charles Clarkson", "author_id": 31788, "author_profile": "https://wordpress.stackexchange.com/users/31788", "pm_score": 4, "selected": true, "text": "<p>I disabled the parent boxes to avoid shifting parents to the left.</p>\n\n<pre><code>add_action( 'admi...
2013/05/04
[ "https://wordpress.stackexchange.com/questions/98274", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25635/" ]
I'm trying to find a way of disabling the selection of the parent category within Wordpress 3.5.1 (post editor screen) **only** when that parent category contains child categories. My structure: * Category 1 (no children, allow users to post, keep selection option) * Galleries (parent category WITH children, remove s...
I disabled the parent boxes to avoid shifting parents to the left. ``` add_action( 'admin_footer-post.php', 'wpse_98274_disable_top_categories_checkboxes' ); add_action( 'admin_footer-post-new.php', 'wpse_98274_disable_top_categories_checkboxes' ); /** * Disable parent checkboxes in Post Editor. */ function wps...
98,284
<p>In the beginning of each page served by WordPress, there is a MySQL call to fetch options:</p> <pre><code>SELECT option_name, option_value FROM wp_options WHERE autoload = 'yes'; </code></pre> <p>Because there's no index on <code>autoload</code> column, MySQL has to lookup ALL rows. </p> <p>I also came across the...
[ { "answer_id": 98287, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 5, "selected": true, "text": "<p>There is no index because the need for it was never strong enough.</p>\n\n<p>In <a href=\"http://core.trac.wordpress.or...
2013/05/04
[ "https://wordpress.stackexchange.com/questions/98284", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26808/" ]
In the beginning of each page served by WordPress, there is a MySQL call to fetch options: ``` SELECT option_name, option_value FROM wp_options WHERE autoload = 'yes'; ``` Because there's no index on `autoload` column, MySQL has to lookup ALL rows. I also came across the comment of [this answer](https://wordpress....
There is no index because the need for it was never strong enough. In [ticket #14258](http://core.trac.wordpress.org/ticket/14258) it was suggested, but since most options use `autoload=yes` by default, the index would be ignored anyway. There is also the still open ticket [#24044 \_Add index to wp\_options to aid/im...
98,300
<p>I need to restrict access to certain frontend pages, based on a user_meta field. </p> <p>All works fine, except when the user is already logged in but with the wrong credentials. In that situation I would want them to be redirected to the login form (with a message encouraging them to logout and login again with su...
[ { "answer_id": 98302, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 1, "selected": false, "text": "<p>When you say that the user is \"logged in but with the wrong credentials\" I have to assume you mean \"the us...
2013/05/04
[ "https://wordpress.stackexchange.com/questions/98300", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8397/" ]
I need to restrict access to certain frontend pages, based on a user\_meta field. All works fine, except when the user is already logged in but with the wrong credentials. In that situation I would want them to be redirected to the login form (with a message encouraging them to logout and login again with suitable cr...
Thanks to @s\_ha\_dum I eventually tracked the issue down to the following line in my `wp-config.php` file... ``` @define('ADMIN_COOKIE_PATH', '/'); ``` Commenting this out solved the problem Ironically, I've tended to include this line as a standard preventative measure against login redirection loops. (Can't reme...
98,304
<p>So when WooCommerce updated to version 2 they replaced the fancybox lightbox scripts with prettyphoto. I would like to use this on all my wordpress site's pages, not just the product pages, but the scripts are only loaded on a product page. I have a jQuery script to add the relevant css class to my image links but I...
[ { "answer_id": 98664, "author": "Sam", "author_id": 26836, "author_profile": "https://wordpress.stackexchange.com/users/26836", "pm_score": 3, "selected": true, "text": "<p>Try adding this to your theme's function.php. It worked for me, hope it helps.</p>\n\n<pre><code>// PRETTY PHOTO //...
2013/05/04
[ "https://wordpress.stackexchange.com/questions/98304", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23620/" ]
So when WooCommerce updated to version 2 they replaced the fancybox lightbox scripts with prettyphoto. I would like to use this on all my wordpress site's pages, not just the product pages, but the scripts are only loaded on a product page. I have a jQuery script to add the relevant css class to my image links but I ne...
Try adding this to your theme's function.php. It worked for me, hope it helps. ``` // PRETTY PHOTO // add_action( 'wp_enqueue_scripts', 'lightbox' ); function lightbox() { global $woocommerce; $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; { wp_enqueue_script( 'prettyPhoto', $woocommerce->plugin_u...
98,317
<p>Does anyone know how to make this page template to only show knowledgebase post types? I've tried various different ways but with no luck</p> <pre><code>&lt;?php $cat_args = array( 'taxonomy' =&gt; 'knowledgebase_category', 'orderby' =&gt; 'slug', 'order' =&gt; 'ASC', 'hierarchical' =&gt; true, 'parent' =&...
[ { "answer_id": 98664, "author": "Sam", "author_id": 26836, "author_profile": "https://wordpress.stackexchange.com/users/26836", "pm_score": 3, "selected": true, "text": "<p>Try adding this to your theme's function.php. It worked for me, hope it helps.</p>\n\n<pre><code>// PRETTY PHOTO //...
2013/05/04
[ "https://wordpress.stackexchange.com/questions/98317", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31891/" ]
Does anyone know how to make this page template to only show knowledgebase post types? I've tried various different ways but with no luck ``` <?php $cat_args = array( 'taxonomy' => 'knowledgebase_category', 'orderby' => 'slug', 'order' => 'ASC', 'hierarchical' => true, 'parent' => 0, 'child_of' => 0 ); ...
Try adding this to your theme's function.php. It worked for me, hope it helps. ``` // PRETTY PHOTO // add_action( 'wp_enqueue_scripts', 'lightbox' ); function lightbox() { global $woocommerce; $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; { wp_enqueue_script( 'prettyPhoto', $woocommerce->plugin_u...
98,326
<p>I would like to disable the MySQL portion of the main query, i.e. I want every step to be followed on this page EXCEPT step 4.3: <a href="http://codex.wordpress.org/Query_Overview" rel="nofollow">http://codex.wordpress.org/Query_Overview</a></p> <p>What's the easiest way to go about doing that?</p>
[ { "answer_id": 98330, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p>It typically hard to throw out completely thing that WP insist on doing during core load process. It is however rela...
2013/05/04
[ "https://wordpress.stackexchange.com/questions/98326", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26725/" ]
I would like to disable the MySQL portion of the main query, i.e. I want every step to be followed on this page EXCEPT step 4.3: <http://codex.wordpress.org/Query_Overview> What's the easiest way to go about doing that?
Check if this solution work for your case: ``` add_filter('posts_request', 'supress_main_query', 10, 2); function supress_main_query( $request, $query ){ if( $query->is_main_query() && ! $query->is_admin ) return false; else return $request; } ``` `posts_request` is the last filter called bef...
98,347
<p>Here is my loop code, i want to call <strong>different page templates</strong> for <strong>different pages</strong>. Please notice that this is a <strong>one-page-layout</strong>.</p> <pre><code>&lt;?php $args = array( 'post_type' =&gt; 'page' );?&gt; &lt;!-- get only pages --&gt; &lt;?php query_posts($args); ?&g...
[ { "answer_id": 98348, "author": "montrealist", "author_id": 8105, "author_profile": "https://wordpress.stackexchange.com/users/8105", "pm_score": 0, "selected": false, "text": "<p>First of all, don't use <code>query_posts</code>. Check <a href=\"https://wordpress.stackexchange.com/questi...
2013/05/05
[ "https://wordpress.stackexchange.com/questions/98347", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32420/" ]
Here is my loop code, i want to call **different page templates** for **different pages**. Please notice that this is a **one-page-layout**. ``` <?php $args = array( 'post_type' => 'page' );?> <!-- get only pages --> <?php query_posts($args); ?> <?php while (have_posts()) : the_post(); ?> <!-- loop with pages star...
Yes, there are a few improvements. * Needlessly opening and closing PHP tags is a timewaster, makes it harder to read, and means more typing * PHP Alt/short style syntax isn't going to play as nicely with the editor. Use {} instead, and your IDE may even help you type out the closing brace automagically. * Query\_post...
98,352
<p>I'm creating a shortcode to display the list of users with a particular profile in WordPress.</p> <p>But I can not enable or display the pagination. I have 25 users on my site and would like to display 5 profile users per page and include the pagination.</p> <p>I added a new Role student, and multiple custom field...
[ { "answer_id": 98348, "author": "montrealist", "author_id": 8105, "author_profile": "https://wordpress.stackexchange.com/users/8105", "pm_score": 0, "selected": false, "text": "<p>First of all, don't use <code>query_posts</code>. Check <a href=\"https://wordpress.stackexchange.com/questi...
2013/05/05
[ "https://wordpress.stackexchange.com/questions/98352", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32422/" ]
I'm creating a shortcode to display the list of users with a particular profile in WordPress. But I can not enable or display the pagination. I have 25 users on my site and would like to display 5 profile users per page and include the pagination. I added a new Role student, and multiple custom fields using Advanced ...
Yes, there are a few improvements. * Needlessly opening and closing PHP tags is a timewaster, makes it harder to read, and means more typing * PHP Alt/short style syntax isn't going to play as nicely with the editor. Use {} instead, and your IDE may even help you type out the closing brace automagically. * Query\_post...
98,358
<p>How it possible to redirect all users, even administrators after login to specific page? And also redirect users after successful registration? Any simplest way? For example I want to redirect users after login, to the "Updates" page of my website. And after registration, to the "Home" page of website. </p>
[ { "answer_id": 98382, "author": "Charles Clarkson", "author_id": 31788, "author_profile": "https://wordpress.stackexchange.com/users/31788", "pm_score": 3, "selected": true, "text": "<p>This code adapted from: <a href=\"https://wordpress.stackexchange.com/questions/19692/how-to-redirect-...
2013/05/05
[ "https://wordpress.stackexchange.com/questions/98358", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31988/" ]
How it possible to redirect all users, even administrators after login to specific page? And also redirect users after successful registration? Any simplest way? For example I want to redirect users after login, to the "Updates" page of my website. And after registration, to the "Home" page of website.
This code adapted from: [Registration Redirect](https://wordpress.stackexchange.com/questions/19692/how-to-redirect-a-sucessful-registration-to-a-page-template) ``` add_filter( 'registration_redirect', 'ckc_registration_redirect' ); function ckc_registration_redirect() { return home_url(); } ``` This code adapte...
98,375
<p>I writing plugin in my profile page and i want to create upload via 'Browse' button and 'Dir' field that will upload and return image url.And i don't want to use media-upload.</p> <p>I used to read <a href="https://wordpress.stackexchange.com/questions/72406/set-featured-image-front-frontend-form/72411#72411">Set F...
[ { "answer_id": 98383, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 3, "selected": false, "text": "<p>There are several parts.</p>\n\n<p>You need to add an <code>enctype</code> to the profile form.</p>\n\n<pre><...
2013/05/05
[ "https://wordpress.stackexchange.com/questions/98375", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32040/" ]
I writing plugin in my profile page and i want to create upload via 'Browse' button and 'Dir' field that will upload and return image url.And i don't want to use media-upload. I used to read [Set Featured Image Front Frontend Form](https://wordpress.stackexchange.com/questions/72406/set-featured-image-front-frontend-f...
There are several parts. You need to add an `enctype` to the profile form. ``` function edit_form_type_wpse_98375() { echo ' enctype="multipart/form-data"'; } add_action('user_edit_form_tag','edit_form_type_wpse_98375'); ``` Then add a field to the form. ``` function user_fields_wpse_98375($profileuser) { $_...
98,386
<p>I am currently developing a wordpress site locally using MAMP PRO, which obviously involves using a local database.</p> <p>I would like to test this site on my iPhone via a remote link. I have managed to do this by typing the following into my mobile phone URL...</p> <pre><code>192.234.2.32:8888 </code></pre> <p...
[ { "answer_id": 98387, "author": "Adam", "author_id": 24587, "author_profile": "https://wordpress.stackexchange.com/users/24587", "pm_score": 0, "selected": false, "text": "<p>Have answered my own question, found this great article which did the trick <a href=\"http://www.designshifts.com...
2013/05/05
[ "https://wordpress.stackexchange.com/questions/98386", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24587/" ]
I am currently developing a wordpress site locally using MAMP PRO, which obviously involves using a local database. I would like to test this site on my iPhone via a remote link. I have managed to do this by typing the following into my mobile phone URL... ``` 192.234.2.32:8888 ``` (IP Address : Port number) The ...
I use xip.io for this. > > ### [What is xip.io?](http://xip.io/) > > > xip.io is a magic domain name that provides wildcard > DNS for any IP address. Say your LAN IP address is 10.0.0.1. Using > xip.io, > > > > ``` > 10.0.0.1.xip.io resolves to 10.0.0.1 > www.10.0.0.1.xip.io resolves to 10.0....
98,390
<p>I have a homepage on which I want to display the latest post different from the other posts. I haven't used <code>post_class</code> and I am not sure how to.</p> <p>Would I be able to achieve what I want using <code>post_class</code>?</p>
[ { "answer_id": 98396, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": true, "text": "<p>You should be using <a href=\"http://codex.wordpress.org/Function_Reference/post_class\" rel=\"nofollow\"><cod...
2013/05/05
[ "https://wordpress.stackexchange.com/questions/98390", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32436/" ]
I have a homepage on which I want to display the latest post different from the other posts. I haven't used `post_class` and I am not sure how to. Would I be able to achieve what I want using `post_class`?
You should be using [`post_class`](http://codex.wordpress.org/Function_Reference/post_class) (and [`body_class`](http://codex.wordpress.org/Function_Reference/body_class) for that matter) but you don't need it for this. Alter your Loop on your home page to conditionally format the first post. ``` $first = (!is_paged()...
98,392
<p>I want to add social share buttons to my posts, but I don’t want to put all that big bulk of code into all my content files. I want to create a function, and then add the function name to my template files, something like this:</p> <pre><code>function pietergoosen_sosiale_netwerk_deel_knoppies() { &lt;strong&gt;De...
[ { "answer_id": 98397, "author": "OriginalEXE", "author_id": 16710, "author_profile": "https://wordpress.stackexchange.com/users/16710", "pm_score": 0, "selected": false, "text": "<p>First of all, you never closed your php tags.</p>\n\n<p>Second of all, do not call functions each time for...
2013/05/05
[ "https://wordpress.stackexchange.com/questions/98392", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31545/" ]
I want to add social share buttons to my posts, but I don’t want to put all that big bulk of code into all my content files. I want to create a function, and then add the function name to my template files, something like this: ``` function pietergoosen_sosiale_netwerk_deel_knoppies() { <strong>Deel die pos met ander...
There are a couple of problems with your code: 1. You have to close the PHP context, if you want to output plain HTML: `function foo(){ ?><strong><?php }` 2. Don’t repeat yourself. Always store repeating values in variables or functions. Writing `<a href` more than once is a bug. 3. Do not use `get_the_title()` in att...
98,414
<p>I am trying to create a theme.</p> <p>I created a <code>header.php</code> file and call this file in <code>index.php</code> using</p> <pre><code>&lt;?php get_header();?&gt; </code></pre> <p>When I try to run my index.php file it shows this error:</p> <blockquote> <p>Call to undefined function <code>get_header...
[ { "answer_id": 98415, "author": "JMau", "author_id": 31376, "author_profile": "https://wordpress.stackexchange.com/users/31376", "pm_score": 1, "selected": false, "text": "<blockquote>\n <p>Generally this happens when someone has mistakenly put index.php from\n a theme in the WP instal...
2013/05/05
[ "https://wordpress.stackexchange.com/questions/98414", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32445/" ]
I am trying to create a theme. I created a `header.php` file and call this file in `index.php` using ``` <?php get_header();?> ``` When I try to run my index.php file it shows this error: > > Call to undefined function `get_header()` > > > What could be wrong?
WordPress theme templates are not meant to be executed directly. They are loaded by WordPress core (after appropriate environment had been set up) according to [Template Hierarchy](http://codex.wordpress.org/Template_Hierarchy).
98,423
<p>At present I'm using this permalink structure <code>/%category%/%postname%/</code>. There are some existing post type. I want to change permalink for image post type to <code>image/%post_id%/</code>, and don't want to affect other post type and their permalinks.</p>
[ { "answer_id": 98424, "author": "Jared Cobb", "author_id": 6737, "author_profile": "https://wordpress.stackexchange.com/users/6737", "pm_score": 0, "selected": false, "text": "<p>I would give the <a href=\"http://wordpress.org/extend/plugins/custom-post-type-permalinks/\" rel=\"nofollow\...
2013/05/05
[ "https://wordpress.stackexchange.com/questions/98423", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29577/" ]
At present I'm using this permalink structure `/%category%/%postname%/`. There are some existing post type. I want to change permalink for image post type to `image/%post_id%/`, and don't want to affect other post type and their permalinks.
This will be done when you [register\_post\_type](http://codex.wordpress.org/Function_Reference/register_post_type) : ``` $args = array( 'rewrite' => array( 'slug' => 'book' ), ); register_post_type( 'book', $args ); ``` IMPORTANT ! Remember to go to wp-admin options > permalink and click SAVE ...
98,469
<p>I'd like to programmatically (either with js or php, but I imagine it'd simpler with js) hide the dashboard admin menu using the same functionality that is already built in.</p> <p>All I want is, when the user clicks on a custom link in the dashboard the admin menu will collapse, so I have more screen space. Does a...
[ { "answer_id": 98504, "author": "Ralf912", "author_id": 16589, "author_profile": "https://wordpress.stackexchange.com/users/16589", "pm_score": 3, "selected": true, "text": "<p>Add a javascript to all admin pages:</p>\n\n<pre><code>add_action( 'admin_print_scripts', 'auto_collapse_menu' ...
2013/05/06
[ "https://wordpress.stackexchange.com/questions/98469", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17588/" ]
I'd like to programmatically (either with js or php, but I imagine it'd simpler with js) hide the dashboard admin menu using the same functionality that is already built in. All I want is, when the user clicks on a custom link in the dashboard the admin menu will collapse, so I have more screen space. Does anyone know...
Add a javascript to all admin pages: ``` add_action( 'admin_print_scripts', 'auto_collapse_menu' ); function auto_collapse_menu(){ wp_enqueue_script( 'autocollapsemenu', plugins_url( 'autocollapsemenu.js', __FILE__ ), array( 'jquery' ), false, true ); } ``` The javascript: ``` jQuery(document).ready( functio...
98,498
<p>Note: tried all old questions and they seem not working in current version of wp</p> <p>I want to export pretty permalinks ( not in db) ,posts title,excerpt and if possible category and tags to csv Please tell me how to</p>
[ { "answer_id": 98613, "author": "George Pearce", "author_id": 7434, "author_profile": "https://wordpress.stackexchange.com/users/7434", "pm_score": 0, "selected": false, "text": "<p>In what way are you trying to output them? This is a rough code, but with adaption it'll do what you want ...
2013/05/06
[ "https://wordpress.stackexchange.com/questions/98498", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22582/" ]
Note: tried all old questions and they seem not working in current version of wp I want to export pretty permalinks ( not in db) ,posts title,excerpt and if possible category and tags to csv Please tell me how to
In what way are you trying to output them? This is a rough code, but with adaption it'll do what you want it to do- bear in mind though that this is PHP so you will need to make a page template with it, or build it into a shortcode. It cannot be used as-is and is not a packaged plugin: ``` <?php $exportposts = get_pos...
98,525
<p>I have a page with the following markup in the site theme footer:</p> <pre><code>&lt;div id="modalpopup"&gt;&lt;div id="inside"&gt;&lt;/div&gt;&lt;/div&gt; </code></pre> <p>I have a variable in the WP db I can retrieve via <code>GetOption()</code> which I would like to stuff into that <code>div#inside</code> on pa...
[ { "answer_id": 98548, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 2, "selected": false, "text": "<p>Two possible solutions here-</p>\n\n<p><strong>Solution one</strong> is to not hardcode the modal markup into the t...
2013/05/06
[ "https://wordpress.stackexchange.com/questions/98525", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17248/" ]
I have a page with the following markup in the site theme footer: ``` <div id="modalpopup"><div id="inside"></div></div> ``` I have a variable in the WP db I can retrieve via `GetOption()` which I would like to stuff into that `div#inside` on page load via jQuery. When I've done AJAX before it's always been upon th...
You would still do this with AJAX, except that instead of firing on some event like a 'click', or 'hover', or `submit`, you would fire the Javascript function on [`jQuery(document).ready`](http://api.jquery.com/ready/) instead. That will execute immediately on page load. It doesn't let you execute the code *before* the...
98,546
<p>here is my custom post type and category:</p> <pre><code>//Register nav register_nav_menus( array( 'main_nav' =&gt; 'Main navigation' ) ); //Custom post types add_action( 'init', 'create_post_type' ); function create_post_type() { register_post_type( 'assets', array( 'labels' =&gt; arra...
[ { "answer_id": 98547, "author": "Phill", "author_id": 18441, "author_profile": "https://wordpress.stackexchange.com/users/18441", "pm_score": 1, "selected": false, "text": "<p>Ugh. Fixed.</p>\n\n<p>You have to show the 2nd category box in screen options, I could only see the default post...
2013/05/06
[ "https://wordpress.stackexchange.com/questions/98546", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18441/" ]
here is my custom post type and category: ``` //Register nav register_nav_menus( array( 'main_nav' => 'Main navigation' ) ); //Custom post types add_action( 'init', 'create_post_type' ); function create_post_type() { register_post_type( 'assets', array( 'labels' => array( '...
To show your custom post types in menu items. Go to menus and select screen options on the top and make sure your custom post type checked. [![enter image description here](https://i.stack.imgur.com/FtsVS.png)](https://i.stack.imgur.com/FtsVS.png)
98,558
<p>I have trouble in getting post in a custom post type category. I have code below but it doesnt work well. It still get posts in another category.</p> <pre><code>&lt;?php $query= null; $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args=array( 'post_type' =&gt; get_post_type(), ...
[ { "answer_id": 98570, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 4, "selected": true, "text": "<p>As far as I know there is no such parameter as <code>post_type_cat</code>, you want to use either <code>cat</code>...
2013/05/07
[ "https://wordpress.stackexchange.com/questions/98558", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31680/" ]
I have trouble in getting post in a custom post type category. I have code below but it doesnt work well. It still get posts in another category. ``` <?php $query= null; $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args=array( 'post_type' => get_post_type(), 'post_status...
As far as I know there is no such parameter as `post_type_cat`, you want to use either `cat` or if querying posts in a custom taxonomy you would use a taxonomy query. Category query example; ``` $query = new WP_Query( 'cat=2,6,17,38' ); ``` or ``` $query = new WP_Query( 'category_name=staff' ); ``` See the follo...
98,563
<p>I've spent a few days researching working with WP static pages - as separate from posts.</p> <p>Although I've found useful guidance, I can't seem to find any good tutorials or worked examples that show me how to work with pages using a modified WordPress Loop that will enable me to filter on specific page criteria ...
[ { "answer_id": 98565, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 1, "selected": false, "text": "<p>I would create an \"Events\" custom post type and then create a \"Call to Action\" custom taxonomy and associate ...
2013/05/07
[ "https://wordpress.stackexchange.com/questions/98563", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31446/" ]
I've spent a few days researching working with WP static pages - as separate from posts. Although I've found useful guidance, I can't seem to find any good tutorials or worked examples that show me how to work with pages using a modified WordPress Loop that will enable me to filter on specific page criteria and extrac...
@userabuser's input provides a useful discussion on using Custom Post Types to solve the customisation need. However, this still left unanswered my main question: > > Can I interrogate a pages template type or custom meta data within a loop? > > > I wanted to use wordpress static pages with a custom template as a...
98,572
<p>I followed <a href="https://wordpress.stackexchange.com/questions/21626/pagination-with-custom-sql-query">this link</a> and created my own custom query with pagination, But I don't really understand how the offset work. </p> <p>This pagination does not work well, and I'm getting zero value for offset: </p> <pre><c...
[ { "answer_id": 98565, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 1, "selected": false, "text": "<p>I would create an \"Events\" custom post type and then create a \"Call to Action\" custom taxonomy and associate ...
2013/05/07
[ "https://wordpress.stackexchange.com/questions/98572", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32509/" ]
I followed [this link](https://wordpress.stackexchange.com/questions/21626/pagination-with-custom-sql-query) and created my own custom query with pagination, But I don't really understand how the offset work. This pagination does not work well, and I'm getting zero value for offset: ``` function spiciest(){ global ...
@userabuser's input provides a useful discussion on using Custom Post Types to solve the customisation need. However, this still left unanswered my main question: > > Can I interrogate a pages template type or custom meta data within a loop? > > > I wanted to use wordpress static pages with a custom template as a...
98,580
<p>I have a custom USER taxonomy called 'label' which also has a custom field of 'sort_order' - I am trying to return a list of users that have the label taxonomy and then sort this list by the sort_order field.</p> <p>So far I have.....</p> <pre><code>&lt;?php $users = get_users( array( 'meta_key' =&gt; 'sort_or...
[ { "answer_id": 98581, "author": "Johannes Pille", "author_id": 9745, "author_profile": "https://wordpress.stackexchange.com/users/9745", "pm_score": 0, "selected": false, "text": "<blockquote>\n <p>I notice that <code>get_users</code> does not support this.</p>\n</blockquote>\n\n<p>Unfo...
2013/05/07
[ "https://wordpress.stackexchange.com/questions/98580", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10247/" ]
I have a custom USER taxonomy called 'label' which also has a custom field of 'sort\_order' - I am trying to return a list of users that have the label taxonomy and then sort this list by the sort\_order field. So far I have..... ``` <?php $users = get_users( array( 'meta_key' => 'sort_order', 'fields' => 'al...
By using this you can get your result in ascending order for sort\_order custom field ``` $users = get_users( array( 'meta_key'=> 'sort_order', 'orderby' => 'meta_value_num', 'order' => 'ASC' ) ); foreach( $users as $user ) { echo '<h4>' . $user_info-> user_firstname . ' ' . $user_info-> user_last...
98,591
<p>I'm probably missing something but somehow my custom post type doesn't display the featured image input field when creating the post. I have the featured image already registered in my functions.php and it does show up at pages and regular posts. But not at my custom post type.</p> <p>This is the code that I've use...
[ { "answer_id": 98597, "author": "Adi", "author_id": 27912, "author_profile": "https://wordpress.stackexchange.com/users/27912", "pm_score": 0, "selected": false, "text": "<p>Well i use some different kind of code, which make custom post, but it work perfectly. which save tags,category,fr...
2013/05/07
[ "https://wordpress.stackexchange.com/questions/98591", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28103/" ]
I'm probably missing something but somehow my custom post type doesn't display the featured image input field when creating the post. I have the featured image already registered in my functions.php and it does show up at pages and regular posts. But not at my custom post type. This is the code that I've used to enabl...
Change this line ``` add_theme_support( 'post-thumbnails'); ``` To ``` add_theme_support( 'post-thumbnails', array('post', 'page','vacature')); ``` I think this will help you.
98,608
<p>On the WordPress Edit Image Screen, I'd like to add a label to show the current compression level and byte file size of the image.</p> <p>Any ideas how to tap into this screen and echo this data?</p> <p>The current settings show:</p> <ul> <li>Date</li> <li>URL</li> <li>File name</li> <li>File type</li> <li>Dimens...
[ { "answer_id": 98611, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": true, "text": "<p>You can try to use the <code>attachment_submitbox_misc_actions</code> filter to add more info to the box. Here...
2013/05/07
[ "https://wordpress.stackexchange.com/questions/98608", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6620/" ]
On the WordPress Edit Image Screen, I'd like to add a label to show the current compression level and byte file size of the image. Any ideas how to tap into this screen and echo this data? The current settings show: * Date * URL * File name * File type * Dimensions I'd like to ad * File Size * File Compression (ec...
You can try to use the `attachment_submitbox_misc_actions` filter to add more info to the box. Here is an example for the filesize part: ![enter image description here](https://i.stack.imgur.com/w2V3l.gif) ``` add_action( 'attachment_submitbox_misc_actions', 'custom_fileinfo_wpse_98608' ); function custom_fileinfo_wp...
98,621
<p>I've written my first simple WP widget-- it all works fine, but I'd like to dress it up a bit, and add an image / logo in the widget display code.</p> <p>How do I package the widget (which is just a single PHP file) with the image, and where will the image be stored in the WP site (so I can create the img tag link ...
[ { "answer_id": 98623, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 1, "selected": false, "text": "<p>You can't distribute/install a widget all by itself. There are several ways to extend WordPress:</p>\n\n<ol>\...
2013/05/07
[ "https://wordpress.stackexchange.com/questions/98621", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32527/" ]
I've written my first simple WP widget-- it all works fine, but I'd like to dress it up a bit, and add an image / logo in the widget display code. How do I package the widget (which is just a single PHP file) with the image, and where will the image be stored in the WP site (so I can create the img tag link correctly)...
It sounds like you'll need the [`plugins_url()` function](http://codex.wordpress.org/plugins_url) which generates the URL for the plugins directory and can handle any alternate configuration (such as if you moved it to the `/mu-plugins/` directory, a personal favorite of mine). The Codex documentation is good, but here...
98,625
<p>I was a bit surprised when I got a message that a comment was awaiting moderation on a website where I have I have turned off <code>Allow people to post comments on new articles</code> and there are no comment fields.</p> <p>How can someone then submit a comment?</p>
[ { "answer_id": 98627, "author": "dipali", "author_id": 20711, "author_profile": "https://wordpress.stackexchange.com/users/20711", "pm_score": 1, "selected": false, "text": "<p>If you have unchecked <code>Allow people to post comments on the article</code> on the <code>Options &gt; Discu...
2013/05/07
[ "https://wordpress.stackexchange.com/questions/98625", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1447/" ]
I was a bit surprised when I got a message that a comment was awaiting moderation on a website where I have I have turned off `Allow people to post comments on new articles` and there are no comment fields. How can someone then submit a comment?
You could also use the hook `pre_comment_on_post` to exit early: ``` add_action( 'pre_comment_on_post', '_scalar_wp_die_handler' ); ``` This will not change the database.
98,629
<p>The theme I'm using includes a slideshow that generates an additional 4 image sizes for every image that is uploaded. I don't need to have all those images being generated for every image. </p> <p>Is there a way to remove the slideshow thumbnail sizes for a custom post type in my child theme?</p> <p>Thanks</p>
[ { "answer_id": 98670, "author": "ckpepper02", "author_id": 18404, "author_profile": "https://wordpress.stackexchange.com/users/18404", "pm_score": 0, "selected": false, "text": "<p>I don't think this is possible. I've been searching for something like this as well and haven't come up wit...
2013/05/07
[ "https://wordpress.stackexchange.com/questions/98629", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21258/" ]
The theme I'm using includes a slideshow that generates an additional 4 image sizes for every image that is uploaded. I don't need to have all those images being generated for every image. Is there a way to remove the slideshow thumbnail sizes for a custom post type in my child theme? Thanks
I think it might be possible, try adding this to your child theme's functions.php ``` add_action('init', 'remove_plugin_image_sizes'); function remove_plugin_image_sizes() { remove_image_size('image-name'); } ``` Here is the documentation: <https://codex.wordpress.org/Function_Reference/remove_image_size>
98,645
<p>That was a very dense title.</p> <p>I have a custom post type "event" which has a Date/Time picker field "event_date" thanks to the Advanced Custom Fields plugin. This Date/Time picker saves a UNIX timestamp to the database. I'm trying to use WP_Query to get all events that are today or in the future. This is the c...
[ { "answer_id": 98646, "author": "Kailey Lampert", "author_id": 11571, "author_profile": "https://wordpress.stackexchange.com/users/11571", "pm_score": 4, "selected": true, "text": "<p>Try an array of arrays in your meta query.</p>\n\n<pre><code>$args = Array(\n 'post_type' =&g...
2013/05/07
[ "https://wordpress.stackexchange.com/questions/98645", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17087/" ]
That was a very dense title. I have a custom post type "event" which has a Date/Time picker field "event\_date" thanks to the Advanced Custom Fields plugin. This Date/Time picker saves a UNIX timestamp to the database. I'm trying to use WP\_Query to get all events that are today or in the future. This is the code that...
Try an array of arrays in your meta query. ``` $args = Array( 'post_type' => 'event', 'posts_per_page' => -1, 'meta_key' => 'event_date', 'orderby' => 'meta_value_num', 'order' => 'ASC', 'meta_query' => array( array( 'key...
98,655
<p>I'm trying to fetch content about the current post into the header.php of my theme (to dynamically insert Facebook OpenGraph Metadata).</p> <p>Since I'm on a single post page, shouldn't it be able to run functions like <code>the_content()</code> or <code>wp_get_attachment_thumb_url()</code>?</p> <pre><code>&lt;?ph...
[ { "answer_id": 98656, "author": "vancoder", "author_id": 26778, "author_profile": "https://wordpress.stackexchange.com/users/26778", "pm_score": 2, "selected": false, "text": "<p>First line of the codex for <a href=\"http://codex.wordpress.org/Function_Reference/the_content\" rel=\"nofol...
2013/05/07
[ "https://wordpress.stackexchange.com/questions/98655", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18228/" ]
I'm trying to fetch content about the current post into the header.php of my theme (to dynamically insert Facebook OpenGraph Metadata). Since I'm on a single post page, shouldn't it be able to run functions like `the_content()` or `wp_get_attachment_thumb_url()`? ``` <?php if (is_single()) { <meta property...
Consider this snippet [here](http://www.paulund.co.uk/add-facebook-open-graph-tags-to-wordpress) to accomplish your task. If you add it to your `functions.php` file, the Open Graph tags will be populated automatically as part of the `wp_head` action.
98,658
<p>I would like to share a document with about 140 users after password authentication and I want to avoid to create manually all the 140 accounts. Is it possible to create them quickly? </p> <p><strong>UPDATE</strong>: usernames to add are stored into a text file. The question is focused on the batch users creation b...
[ { "answer_id": 98659, "author": "Eric Jorgensen", "author_id": 32537, "author_profile": "https://wordpress.stackexchange.com/users/32537", "pm_score": 1, "selected": false, "text": "<p>You'll need a plugin to do batch import.</p>\n\n<p>This <a href=\"http://wordpress.org/extend/plugins/i...
2013/05/07
[ "https://wordpress.stackexchange.com/questions/98658", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32536/" ]
I would like to share a document with about 140 users after password authentication and I want to avoid to create manually all the 140 accounts. Is it possible to create them quickly? **UPDATE**: usernames to add are stored into a text file. The question is focused on the batch users creation because I will create a ...
This is a small code I wrote to batch create generic users ``` <?php $lock = true; //true = disabled (locked) if(!$lock) { // if not locked require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' ); $last_registered_user = $wpdb->get_row("SELECT ID FROM $wpdb->users ORDER BY ID DESC LIMIT 1"); $new_id =...
98,755
<p>I have a list of categories in woo-commerce which I'm trying to customize to be displayed to look like the following image.</p> <p><img src="https://i.stack.imgur.com/PwUHl.png" alt="List of categories"></p> <p>I created the above image using normal HTML and css however I would like to now convert it to WordPress ...
[ { "answer_id": 98930, "author": "gdaniel", "author_id": 30984, "author_profile": "https://wordpress.stackexchange.com/users/30984", "pm_score": 0, "selected": false, "text": "<p>Oudin,</p>\n\n<p>I will answer here the CSS part of your question:</p>\n\n<p>Use this to remove the list bulle...
2013/05/08
[ "https://wordpress.stackexchange.com/questions/98755", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17073/" ]
I have a list of categories in woo-commerce which I'm trying to customize to be displayed to look like the following image. ![List of categories](https://i.stack.imgur.com/PwUHl.png) I created the above image using normal HTML and css however I would like to now convert it to WordPress in order to have it dynamically...
Even if a `wp_list_categories` filter exists, it passes (and so you have to return) the html markup generated by `wp_list_categories()` function. This means that if you want use that filter you have to alter the DOM with php, and even if it's possible (hopefully using external php libraries), sure it's not the best sol...
98,757
<p>I have three Javascript script that I need to load - </p> <ul> <li><code>imagesLoaded.js</code> </li> <li><code>lazyload-1.8.4.js</code></li> <li>and <code>cd.js</code></li> </ul> <p><code>cd.js</code> contains my functions that use <code>imagesLoaded.js</code> and <code>lazyload-1.8.4.js</code>.</p> <p>Do load t...
[ { "answer_id": 98761, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 4, "selected": true, "text": "<p>I formatted that code as best I could, and once formatted it is obviously very broken. <a href=\"http://codex....
2013/05/08
[ "https://wordpress.stackexchange.com/questions/98757", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31546/" ]
I have three Javascript script that I need to load - * `imagesLoaded.js` * `lazyload-1.8.4.js` * and `cd.js` `cd.js` contains my functions that use `imagesLoaded.js` and `lazyload-1.8.4.js`. Do load them altogether or separately? ``` function add_my_script() { wp_enqueue_script( 'imagesLoaded', get_templ...
I formatted that code as best I could, and once formatted it is obviously very broken. [`wp_enqueue_script`](http://codex.wordpress.org/Function_Reference/wp_enqueue_script) takes 5 parameters. You have 9. And several of the first five are wrong. I expect that you would see errors if you had [debugging enabled](http://...
98,762
<p>If we set wp to break comments into pages after X nr of comments and we have X+1 comments , wp only shows that last comment instead of showing X and move the comment from bottom onto the next page. Any help would be appreciated since it is a big deal for what I am trying to use it.</p>
[ { "answer_id": 98810, "author": "montrealist", "author_id": 8105, "author_profile": "https://wordpress.stackexchange.com/users/8105", "pm_score": 0, "selected": false, "text": "<p>In wp-admin, go to <code>Settings</code> -> <code>Discussion</code> -> <code>Break comments into pages with ...
2013/05/08
[ "https://wordpress.stackexchange.com/questions/98762", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32412/" ]
If we set wp to break comments into pages after X nr of comments and we have X+1 comments , wp only shows that last comment instead of showing X and move the comment from bottom onto the next page. Any help would be appreciated since it is a big deal for what I am trying to use it.
ok.. so I did it like this. Maybe will help some. Used the code from [Last comment page first with full number of comments?](https://wordpress.stackexchange.com/questions/13826/last-comment-page-first-with-full-number-of-comments) but altered it a bit to fit my needs. So this goes into your template page where you call...
98,778
<p>I am trying to have a section under a single post where it displays completely random posts. I got everything working, but every once in a while one of the random posts that get displayed is the actual post that it is on (the single).</p> <p>Here is my code:</p> <pre><code>&lt;?php $args = array( 'numberposts' =&g...
[ { "answer_id": 98779, "author": "Bryan Monzon", "author_id": 32385, "author_profile": "https://wordpress.stackexchange.com/users/32385", "pm_score": 1, "selected": false, "text": "<p>Just before this you can run <code>&lt;?php print_r( $post ); ?&gt;</code> and if it returns an array, th...
2013/05/08
[ "https://wordpress.stackexchange.com/questions/98778", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32290/" ]
I am trying to have a section under a single post where it displays completely random posts. I got everything working, but every once in a while one of the random posts that get displayed is the actual post that it is on (the single). Here is my code: ``` <?php $args = array( 'numberposts' => 3, 'orderby' => 'rand' )...
Check to see if you have a post ID (which you should on a single post page but I am not sure if this is in `single.php` or some other template like `index.php`) and add that to the `$args` if you do. ``` $args = array( 'numberposts' => 3, 'orderby' => 'rand' ); if (is_singular() && isset($post->ID)) { $args['exclude...
98,799
<p>I have created custom Wordpress loop using WP_Query, loop is working fine and I can customize it nicely, however i have a problem using "Blog pages show at most" settings, for example inside my loop if i have added following argument <code>'post_per_page' =&gt;-1</code> my loop is showing all posts but now i <b>can'...
[ { "answer_id": 98803, "author": "vancoder", "author_id": 26778, "author_profile": "https://wordpress.stackexchange.com/users/26778", "pm_score": 3, "selected": true, "text": "<p>I'm not sure why your blank variable method should work, but it seems dodgy to me. I would explicitly set the ...
2013/05/08
[ "https://wordpress.stackexchange.com/questions/98799", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20941/" ]
I have created custom Wordpress loop using WP\_Query, loop is working fine and I can customize it nicely, however i have a problem using "Blog pages show at most" settings, for example inside my loop if i have added following argument `'post_per_page' =>-1` my loop is showing all posts but now i **can't insert my custo...
I'm not sure why your blank variable method should work, but it seems dodgy to me. I would explicitly set the posts\_per\_page to the number defined in settings: ``` 'posts_per_page' => get_option( 'posts_per_page' ) ```
98,851
<p>I'm using the following widget to retrieve a list of the custom post type <strong>jobs</strong>:</p> <pre><code>class FeaturedJobsWidget extends WP_Widget { function FeaturedJobsWidget() { $widget_ops = array('classname' =&gt; 'FeaturedJobsWidget', 'description' =&gt; 'Displays a random post with thumbnail'...
[ { "answer_id": 98853, "author": "Vinod Dalvi", "author_id": 14347, "author_profile": "https://wordpress.stackexchange.com/users/14347", "pm_score": 3, "selected": true, "text": "<p>Use <a href=\"http://codex.wordpress.org/Function_Reference/wp_reset_postdata\" rel=\"nofollow\">wp_reset_p...
2013/05/09
[ "https://wordpress.stackexchange.com/questions/98851", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/781/" ]
I'm using the following widget to retrieve a list of the custom post type **jobs**: ``` class FeaturedJobsWidget extends WP_Widget { function FeaturedJobsWidget() { $widget_ops = array('classname' => 'FeaturedJobsWidget', 'description' => 'Displays a random post with thumbnail' ); $this->WP_Widget('Feature...
Use [wp\_reset\_postdata](http://codex.wordpress.org/Function_Reference/wp_reset_postdata)() function after while loop to reset custom wp\_query as shown in following code so that it will not break other wordpress loop. ``` <?php // Create and run custom loop $custom_posts = new WP_Query(); $custom_posts->qu...
98,874
<p>I am trying to get the woocommerce products by category.. When I query using the wpdb it gets the product correctly which exists in the backend products list. But when I query using the query_posts it gets another set of products that is not listed in the backend.</p> <p>Why this discrepancy?</p> <pre><code> g...
[ { "answer_id": 98853, "author": "Vinod Dalvi", "author_id": 14347, "author_profile": "https://wordpress.stackexchange.com/users/14347", "pm_score": 3, "selected": true, "text": "<p>Use <a href=\"http://codex.wordpress.org/Function_Reference/wp_reset_postdata\" rel=\"nofollow\">wp_reset_p...
2013/05/09
[ "https://wordpress.stackexchange.com/questions/98874", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29259/" ]
I am trying to get the woocommerce products by category.. When I query using the wpdb it gets the product correctly which exists in the backend products list. But when I query using the query\_posts it gets another set of products that is not listed in the backend. Why this discrepancy? ``` global $post, $wpdb; ...
Use [wp\_reset\_postdata](http://codex.wordpress.org/Function_Reference/wp_reset_postdata)() function after while loop to reset custom wp\_query as shown in following code so that it will not break other wordpress loop. ``` <?php // Create and run custom loop $custom_posts = new WP_Query(); $custom_posts->qu...
98,904
<p>I am an admin of a multi-author blog. I am implementing a monitoring system which will require me to downgrade a user from an 'author' (this role allows them to make a custom post) back to the 'reader' role if I think it is a spam account, or if they are breaking website rules.</p> <p>After changing their role usi...
[ { "answer_id": 98908, "author": "Pat J", "author_id": 16121, "author_profile": "https://wordpress.stackexchange.com/users/16121", "pm_score": 3, "selected": true, "text": "<p>You can add actions to the <a href=\"https://codex.wordpress.org/Plugin_API/Action_Reference/set_user_role\" rel=...
2013/05/09
[ "https://wordpress.stackexchange.com/questions/98904", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28123/" ]
I am an admin of a multi-author blog. I am implementing a monitoring system which will require me to downgrade a user from an 'author' (this role allows them to make a custom post) back to the 'reader' role if I think it is a spam account, or if they are breaking website rules. After changing their role using the admi...
You can add actions to the [`set_user_role`](https://codex.wordpress.org/Plugin_API/Action_Reference/set_user_role) hook: ``` add_action( 'set_user_role', 'wpse98904_remove_demoted_user_posts', 10, 2 ); function wpse98904_remove_demoted_user_posts( $demoted_author_id, $role ) { if( 'subscriber' == $role ) { ...
98,913
<p>This code works well to display child pages of the parent page while viewing both the parent page and child page. It doesn't apply the <code>current_page_item</code> CSS class to the parent while viewing it (and only it, not interested in it being applied while on the children) - any suggestions?</p> <pre><code>&l...
[ { "answer_id": 99900, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": true, "text": "<p>If I understand what you want, it is trickier than it should be to get it working. </p>\n\n<pre><code>$ancesto...
2013/05/09
[ "https://wordpress.stackexchange.com/questions/98913", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5205/" ]
This code works well to display child pages of the parent page while viewing both the parent page and child page. It doesn't apply the `current_page_item` CSS class to the parent while viewing it (and only it, not interested in it being applied while on the children) - any suggestions? ``` <ul class="subpages"> <?php ...
If I understand what you want, it is trickier than it should be to get it working. ``` $ancestors = array(); $ancestors = get_ancestors($post->ID,'page'); $parent = (!empty($ancestors)) ? array_pop($ancestors) : $post->ID; if (!empty($parent)) { $pages = get_pages(array('child_of'=>$parent)); if (!empty($pages)) ...
98,915
<p>Here is my loop</p> <pre><code>&lt;?php if ( have_posts() ) : ?&gt; &lt;?php /* Start the Loop */ ?&gt; &lt;?php $i = 0; while ( have_posts() ) : the_post(); ?&gt; &lt;?php if ($i++ == 0) : ?&gt; &lt;div class="entry-content-main"&gt; &lt;?php get_template_part( 'content', get_post_f...
[ { "answer_id": 98923, "author": "Michael", "author_id": 4884, "author_profile": "https://wordpress.stackexchange.com/users/4884", "pm_score": 3, "selected": true, "text": "<p>you could rewrite the full code and use the build-in loop counter <code>$wp_query-&gt;current_post</code> to fix ...
2013/05/09
[ "https://wordpress.stackexchange.com/questions/98915", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31545/" ]
Here is my loop ``` <?php if ( have_posts() ) : ?> <?php /* Start the Loop */ ?> <?php $i = 0; while ( have_posts() ) : the_post(); ?> <?php if ($i++ == 0) : ?> <div class="entry-content-main"> <?php get_template_part( 'content', get_post_format() ); ?> </div> <?php else: ?...
you could rewrite the full code and use the build-in loop counter `$wp_query->current_post` to fix the css classses and add a class for the first post per row to clear the float to prevent the 'wacky sticking'; example: ``` <?php if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_post(); ?> <?php /...
98,929
<p>I have built a plugin that fires an Ajax call to connect to a third-party API. That API returns some Json, which I then save as a custom post with <code>wp_insert_post</code>.</p> <p>Now, usually, this works. But, now and again, the save fails, with a "MySQL server has gone away" error. I'm assuming this is because...
[ { "answer_id": 98923, "author": "Michael", "author_id": 4884, "author_profile": "https://wordpress.stackexchange.com/users/4884", "pm_score": 3, "selected": true, "text": "<p>you could rewrite the full code and use the build-in loop counter <code>$wp_query-&gt;current_post</code> to fix ...
2013/05/09
[ "https://wordpress.stackexchange.com/questions/98929", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26778/" ]
I have built a plugin that fires an Ajax call to connect to a third-party API. That API returns some Json, which I then save as a custom post with `wp_insert_post`. Now, usually, this works. But, now and again, the save fails, with a "MySQL server has gone away" error. I'm assuming this is because the API took too lon...
you could rewrite the full code and use the build-in loop counter `$wp_query->current_post` to fix the css classses and add a class for the first post per row to clear the float to prevent the 'wacky sticking'; example: ``` <?php if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_post(); ?> <?php /...
98,937
<p>I am trying to restrict access to wp-admin so that only administrators and editors are allowed. At the moment I am using this function:</p> <pre><code>function restrict_admin(){ //if not administrator, kill WordPress execution and provide a message if ( ! current_user_can( 'manage_options' ) ) { wp_...
[ { "answer_id": 98938, "author": "Andrew Bartel", "author_id": 17879, "author_profile": "https://wordpress.stackexchange.com/users/17879", "pm_score": 2, "selected": false, "text": "<p>You're correct in that you should be checking for a capability. However, manage options is only given t...
2013/05/09
[ "https://wordpress.stackexchange.com/questions/98937", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I am trying to restrict access to wp-admin so that only administrators and editors are allowed. At the moment I am using this function: ``` function restrict_admin(){ //if not administrator, kill WordPress execution and provide a message if ( ! current_user_can( 'manage_options' ) ) { wp_die( __('You a...
You're correct in that you should be checking for a capability. However, manage options is only given to administrators by default. You should check against a capability that both editors and administrators have such as delete\_others\_posts. ``` function restrict_admin(){ //if not administrator, kill WordPress execut...
98,945
<p>I have got a shortcode that displays a custom post type, via a <code>foreach</code>. The shortcode has been used in the standard post type. I have used <code>the_title();</code> in the shortcode. <code>the_title();</code> outputs the post_title of the standard post type (which the shortcode is in), rather than <code...
[ { "answer_id": 98946, "author": "vancoder", "author_id": 26778, "author_profile": "https://wordpress.stackexchange.com/users/26778", "pm_score": 2, "selected": true, "text": "<p>You need to add <code>setup_postdata($post);</code> inside your loop:</p>\n\n<pre><code> foreach ( $attachm...
2013/05/09
[ "https://wordpress.stackexchange.com/questions/98945", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I have got a shortcode that displays a custom post type, via a `foreach`. The shortcode has been used in the standard post type. I have used `the_title();` in the shortcode. `the_title();` outputs the post\_title of the standard post type (which the shortcode is in), rather than `the_title();` of the custom post type. ...
You need to add `setup_postdata($post);` inside your loop: ``` foreach ( $attachments as $post ) { setup_postdata($post); the_title(); the_content(); } ```
98,959
<p>I use a plugin called <a href="http://wordpress.org/extend/plugins/wp-original-source/" rel="nofollow">WP original Source</a>.</p> <p>It lets me add the URL of the original article source, which is handy as it credits the original source of article extracts and summaries that I publish of my website.</p> <p>This U...
[ { "answer_id": 98946, "author": "vancoder", "author_id": 26778, "author_profile": "https://wordpress.stackexchange.com/users/26778", "pm_score": 2, "selected": true, "text": "<p>You need to add <code>setup_postdata($post);</code> inside your loop:</p>\n\n<pre><code> foreach ( $attachm...
2013/05/10
[ "https://wordpress.stackexchange.com/questions/98959", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32660/" ]
I use a plugin called [WP original Source](http://wordpress.org/extend/plugins/wp-original-source/). It lets me add the URL of the original article source, which is handy as it credits the original source of article extracts and summaries that I publish of my website. This URL is then published as metadata in the sou...
You need to add `setup_postdata($post);` inside your loop: ``` foreach ( $attachments as $post ) { setup_postdata($post); the_title(); the_content(); } ```
98,965
<p>I'm trying to pull multiple sites posts. For example, I can pull out a single site posts by a category and total posts 10.</p> <p>But I'm trying to pull out both posts from two separate Multisite blogs 1 &amp; 2. But only blog 1 works. Also, I want to pull out another category from blog 1 and blog 2 by another cate...
[ { "answer_id": 98978, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 5, "selected": true, "text": "<p>The WordPress function <code>switch_to_blog()</code> expects an integer as an input parameter. You can read mor...
2013/05/10
[ "https://wordpress.stackexchange.com/questions/98965", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17354/" ]
I'm trying to pull multiple sites posts. For example, I can pull out a single site posts by a category and total posts 10. But I'm trying to pull out both posts from two separate Multisite blogs 1 & 2. But only blog 1 works. Also, I want to pull out another category from blog 1 and blog 2 by another category. How can ...
The WordPress function `switch_to_blog()` expects an integer as an input parameter. You can read more about it in the Codex: <http://codex.wordpress.org/Function_Reference/switch_to_blog> Please try this kind of structure instead: ``` // Get the current blog id $original_blog_id = get_current_blog_id(); // All the...
98,968
<p>I want to use the post author's avatar if available as the post preview image for Facebook shared posts. If that is not available next would be a featured image and then a default image as a fallback. Is there a plugin or function that can achieve this?</p> <p>The <a href="http://yoast.com/wordpress/seo/#utm_sourc...
[ { "answer_id": 98972, "author": "Ralf912", "author_id": 16589, "author_profile": "https://wordpress.stackexchange.com/users/16589", "pm_score": 0, "selected": false, "text": "<p>This function extract the author from a facebook post link and get the url to the authors facebook avatar</p>\...
2013/05/10
[ "https://wordpress.stackexchange.com/questions/98968", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7318/" ]
I want to use the post author's avatar if available as the post preview image for Facebook shared posts. If that is not available next would be a featured image and then a default image as a fallback. Is there a plugin or function that can achieve this? The [Yoast SEO plugin](http://yoast.com/wordpress/seo/#utm_source...
From your comments, it seems you want to replace the post preview on facebook. This could be hard, because you try to modify the behavior of another webpage. With the [opengraph protocol](https://developers.facebook.com/docs/opengraphprotocol/) it can be done. ``` add_action( 'wp_head', 'get_facebook_meta_tags', 10, 0...
99,003
<p>I have a form that I created by simply using the HTML editor in the wp-admin backend for a page. I have some variables in a hook for that page, I would like to pre-populate some of the form fields with the variables in the hook.</p> <pre><code>add_action('wp', 'simple_form'); function simple_form(){ $firstname...
[ { "answer_id": 98972, "author": "Ralf912", "author_id": 16589, "author_profile": "https://wordpress.stackexchange.com/users/16589", "pm_score": 0, "selected": false, "text": "<p>This function extract the author from a facebook post link and get the url to the authors facebook avatar</p>\...
2013/05/10
[ "https://wordpress.stackexchange.com/questions/99003", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32677/" ]
I have a form that I created by simply using the HTML editor in the wp-admin backend for a page. I have some variables in a hook for that page, I would like to pre-populate some of the form fields with the variables in the hook. ``` add_action('wp', 'simple_form'); function simple_form(){ $firstname = 'Bob'; ...
From your comments, it seems you want to replace the post preview on facebook. This could be hard, because you try to modify the behavior of another webpage. With the [opengraph protocol](https://developers.facebook.com/docs/opengraphprotocol/) it can be done. ``` add_action( 'wp_head', 'get_facebook_meta_tags', 10, 0...
99,027
<p>I want to remove all the links from my network login page ("Register","Lost your password" and "Back to site") how can i do that?</p> <p><img src="https://i.stack.imgur.com/bBHmF.jpg" alt="enter image description here"></p>
[ { "answer_id": 99028, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 4, "selected": true, "text": "<p>I am not sure there is a way to suppress all these links, but you can hide them with CSS:</p>\n\n<pre><code>add_action(...
2013/05/10
[ "https://wordpress.stackexchange.com/questions/99027", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29072/" ]
I want to remove all the links from my network login page ("Register","Lost your password" and "Back to site") how can i do that? ![enter image description here](https://i.stack.imgur.com/bBHmF.jpg)
I am not sure there is a way to suppress all these links, but you can hide them with CSS: ``` add_action( 'login_head', 'hide_login_nav' ); function hide_login_nav() { ?><style>#nav,#backtoblog{display:none}</style><?php } ``` ### Result: ![enter image description here](https://i.stack.imgur.com/V4iyg.png)
99,034
<p>i want author can not see some category from author admin panel but administrator can see that.how i can hide some category?my site <a href="http://techjagot.com" rel="nofollow">http://techjagot.com</a> ..</p> <p>here show some function.php code</p> <pre><code>&lt;?php // Theme Settings Page require_once(TEMPLATE...
[ { "answer_id": 99028, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 4, "selected": true, "text": "<p>I am not sure there is a way to suppress all these links, but you can hide them with CSS:</p>\n\n<pre><code>add_action(...
2013/05/10
[ "https://wordpress.stackexchange.com/questions/99034", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22576/" ]
i want author can not see some category from author admin panel but administrator can see that.how i can hide some category?my site <http://techjagot.com> .. here show some function.php code ``` <?php // Theme Settings Page require_once(TEMPLATEPATH . "/theme-settings.php"); // Theme Styles require_once(TEMPLATEPAT...
I am not sure there is a way to suppress all these links, but you can hide them with CSS: ``` add_action( 'login_head', 'hide_login_nav' ); function hide_login_nav() { ?><style>#nav,#backtoblog{display:none}</style><?php } ``` ### Result: ![enter image description here](https://i.stack.imgur.com/V4iyg.png)
99,039
<h3>Problem:</h3> <p>The WordPress iPhone app (and other WordPress-related smartphone apps) do not allow for much other than the Title and Body fields (i.e. no access to custom fields).</p> <h3>Goal:</h3> <p>My current project requires that we give our mobile bloggers the option to include a subhead with their mobil...
[ { "answer_id": 99059, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>I am not sure I understand your issue right, but my guess is your conundrum - how to get to the title that is unchan...
2013/05/10
[ "https://wordpress.stackexchange.com/questions/99039", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32387/" ]
### Problem: The WordPress iPhone app (and other WordPress-related smartphone apps) do not allow for much other than the Title and Body fields (i.e. no access to custom fields). ### Goal: My current project requires that we give our mobile bloggers the option to include a subhead with their mobile (and desktop) post...
I am not sure I understand your issue right, but my guess is your conundrum - how to get to the title that is unchanged by your filter, if you are filtering it everywhere? You can use [`get_post_field()`](http://queryposts.com/function/get_post_field/) function to get a raw copy of it from the post object. However in...
99,041
<p>On the Plugins screen I have options to activate and deactivate plugins, but I no longer have the "Delete" option. I'm relatively sure the option appeared earlier. </p> <p>Also, when I hover over "Plugins" on the admin menu I don't get the usual popup submenu showing "Install New / Add / Editor". And when I click t...
[ { "answer_id": 99046, "author": "Andy Giesler", "author_id": 3864, "author_profile": "https://wordpress.stackexchange.com/users/3864", "pm_score": 3, "selected": false, "text": "<p>D'oh. </p>\n\n<p>I fixed it, but I'll leave this question in case others have similar problems.</p>\n\n<p>W...
2013/05/10
[ "https://wordpress.stackexchange.com/questions/99041", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3864/" ]
On the Plugins screen I have options to activate and deactivate plugins, but I no longer have the "Delete" option. I'm relatively sure the option appeared earlier. Also, when I hover over "Plugins" on the admin menu I don't get the usual popup submenu showing "Install New / Add / Editor". And when I click the Plugins...
D'oh. I fixed it, but I'll leave this question in case others have similar problems. When copy/pasting various options into wp-config.php I accidentally included this setting, which I don't normally use: ``` // Overkill but FYI: disallows installation/updating of any theme or plugin define('DISALLOW_FILE_MODS',true...
99,070
<p>I have been trying to use the <a href="https://codex.wordpress.org/Function_Reference/unzip_file" rel="nofollow"><code>unzip_file()</code></a> function. It says <code>undefined</code> so I looked into it and the <a href="https://codex.wordpress.org/Filesystem_API" rel="nofollow"><code>WP_Filesystem()</code></a> must...
[ { "answer_id": 99078, "author": "Ralf912", "author_id": 16589, "author_profile": "https://wordpress.stackexchange.com/users/16589", "pm_score": 1, "selected": false, "text": "<pre><code>require_once(ABSPATH .'/wp-admin/includes/file.php');\n\nglobal $wp_filesystem;\nif ( ! $filesystem ) ...
2013/05/11
[ "https://wordpress.stackexchange.com/questions/99070", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29565/" ]
I have been trying to use the [`unzip_file()`](https://codex.wordpress.org/Function_Reference/unzip_file) function. It says `undefined` so I looked into it and the [`WP_Filesystem()`](https://codex.wordpress.org/Filesystem_API) must be called and set up. So easy, right? ``` require_once(ABSPATH .'/wp-admin/includes/fi...
``` require_once(ABSPATH .'/wp-admin/includes/file.php'); global $wp_filesystem; if ( ! $filesystem ) { WP_Filesystem(); if ( ! $wp_filesystem ) nuke_the_world_because_wpfs_cannot_be_initialized_in_case_of_missing_arguments('!'); } $result = unzip_file( $zip, $dest ); if ( is_wp_error( $result ) ) nuke...
99,083
<p>I haven't been able to find what I'm looking for and not sure how to approach it.</p> <p>I'm using <code>wp_list_categories</code> to obviously list terms of a taxonomy. I'd like to add some text to the end of each item.</p> <p>Example being: <li>taxonomy_term some_new_text</li> instead of <li>taxonomy_term</li></...
[ { "answer_id": 99078, "author": "Ralf912", "author_id": 16589, "author_profile": "https://wordpress.stackexchange.com/users/16589", "pm_score": 1, "selected": false, "text": "<pre><code>require_once(ABSPATH .'/wp-admin/includes/file.php');\n\nglobal $wp_filesystem;\nif ( ! $filesystem ) ...
2013/05/11
[ "https://wordpress.stackexchange.com/questions/99083", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5295/" ]
I haven't been able to find what I'm looking for and not sure how to approach it. I'm using `wp_list_categories` to obviously list terms of a taxonomy. I'd like to add some text to the end of each item. Example being: - taxonomy\_term some\_new\_text instead of - taxonomy\_term Here's the basic `wp_list_categories`...
``` require_once(ABSPATH .'/wp-admin/includes/file.php'); global $wp_filesystem; if ( ! $filesystem ) { WP_Filesystem(); if ( ! $wp_filesystem ) nuke_the_world_because_wpfs_cannot_be_initialized_in_case_of_missing_arguments('!'); } $result = unzip_file( $zip, $dest ); if ( is_wp_error( $result ) ) nuke...
99,107
<p>I want to add screen options to my plugin settings page, like the ones that are available in the Dashboard.</p> <p><img src="https://i.stack.imgur.com/GoD60.png" alt="enter image description here"></p> <p>I tried using the <code>add_option</code> method of the <code>WP_Screen</code> object and found that it suppor...
[ { "answer_id": 99222, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 4, "selected": true, "text": "<p>You don’t need to invent a new screen option row. Just use proper metaboxes.</p>\n\n<p>Currently, you are drawing pseud...
2013/05/11
[ "https://wordpress.stackexchange.com/questions/99107", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24579/" ]
I want to add screen options to my plugin settings page, like the ones that are available in the Dashboard. ![enter image description here](https://i.stack.imgur.com/GoD60.png) I tried using the `add_option` method of the `WP_Screen` object and found that it supports only two options. `per_page` and `layout_columns`....
You don’t need to invent a new screen option row. Just use proper metaboxes. Currently, you are drawing pseudo-metaboxes: ``` <!-- Post status start--> <div class = "postbox"> <div class = "handlediv"> <br> </div> <h3 class = "hndle"><span><?php _e("By Post Status", 'bulk-delete'); ?><...
99,160
<p>Pseudo code might look like:</p> <pre><code>if it's this type of post display comments and comment box otherwise forget it </code></pre> <p>This same type of code should also allow someone to have HTTP requests if it's some page, or some kind of page/post but not all of them. </p>
[ { "answer_id": 99172, "author": "Patrick Müller", "author_id": 32747, "author_profile": "https://wordpress.stackexchange.com/users/32747", "pm_score": 1, "selected": false, "text": "<p>In principle you should be able to achieve that by using categories for your posts. So while your norma...
2013/05/12
[ "https://wordpress.stackexchange.com/questions/99160", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32740/" ]
Pseudo code might look like: ``` if it's this type of post display comments and comment box otherwise forget it ``` This same type of code should also allow someone to have HTTP requests if it's some page, or some kind of page/post but not all of them.
In principle you should be able to achieve that by using categories for your posts. So while your normal loop for the single.php might look like this (I'll just leave the markup I had in there since I took this out of a file I had lying around. It may of course be different from yours.) ``` <?php if ( have_posts() ) :...
99,178
<p>I added open graph meta data to all the posts on a site, however, when I attempt to paste a post link on Facebook, the graph meta information isn't loaded.</p> <p>Then, when I insert the URL <a href="https://developers.facebook.com/tools/debug" rel="nofollow noreferrer">into the debugger / linter</a>, it works, bot...
[ { "answer_id": 99207, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 3, "selected": true, "text": "<p>First, this isn't a WordPress specific question, it's a Facebook question.</p>\n\n<p>Secondly, Facebook caches pages...
2013/05/12
[ "https://wordpress.stackexchange.com/questions/99178", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18228/" ]
I added open graph meta data to all the posts on a site, however, when I attempt to paste a post link on Facebook, the graph meta information isn't loaded. Then, when I insert the URL [into the debugger / linter](https://developers.facebook.com/tools/debug), it works, both within the debugger and when posting normally...
First, this isn't a WordPress specific question, it's a Facebook question. Secondly, Facebook caches pages, they don't crawl them on every submission. If you have a URL that has already been submitted to Facebook before, then they will have already crawled it for the OG data once before, and saved it to their cache. I...
99,187
<p>I want to be able to use a function called DisplayAverageRating for each of all the posts I list on a page. The function can be found here: <a href="http://pastebin.com/iXym00QM" rel="nofollow">http://pastebin.com/iXym00QM</a></p> <p>How am I supposed to call it in my code for the average rating for each post to be...
[ { "answer_id": 99207, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 3, "selected": true, "text": "<p>First, this isn't a WordPress specific question, it's a Facebook question.</p>\n\n<p>Secondly, Facebook caches pages...
2013/05/12
[ "https://wordpress.stackexchange.com/questions/99187", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32751/" ]
I want to be able to use a function called DisplayAverageRating for each of all the posts I list on a page. The function can be found here: <http://pastebin.com/iXym00QM> How am I supposed to call it in my code for the average rating for each post to be shown? This is how far I've gotten but it's not working yet: ``...
First, this isn't a WordPress specific question, it's a Facebook question. Secondly, Facebook caches pages, they don't crawl them on every submission. If you have a URL that has already been submitted to Facebook before, then they will have already crawled it for the OG data once before, and saved it to their cache. I...
99,240
<p>I'm working some API. Core is WordPress. Okay, let me paste a sample:</p> <pre><code>&lt;?php include_once('../wp-blog-header.php'); $roll= esc_attr($_GET['roll']); if ( $roll != "" ) { $args = array( 'meta_key' =&gt; 'std_roll', 'meta_value' =&gt; $roll, ); $blogusers = get_users($args); for...
[ { "answer_id": 99207, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 3, "selected": true, "text": "<p>First, this isn't a WordPress specific question, it's a Facebook question.</p>\n\n<p>Secondly, Facebook caches pages...
2013/05/13
[ "https://wordpress.stackexchange.com/questions/99240", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8096/" ]
I'm working some API. Core is WordPress. Okay, let me paste a sample: ``` <?php include_once('../wp-blog-header.php'); $roll= esc_attr($_GET['roll']); if ( $roll != "" ) { $args = array( 'meta_key' => 'std_roll', 'meta_value' => $roll, ); $blogusers = get_users($args); foreach ($blogusers as $us...
First, this isn't a WordPress specific question, it's a Facebook question. Secondly, Facebook caches pages, they don't crawl them on every submission. If you have a URL that has already been submitted to Facebook before, then they will have already crawled it for the OG data once before, and saved it to their cache. I...
99,251
<p><a href="http://redrokk.com/wordpress/wp-content/uploads/2012/07/blank_wordpress_login_form1.png" rel="nofollow">http://redrokk.com/wordpress/wp-content/uploads/2012/07/blank_wordpress_login_form1.png</a></p> <p>I want to add a custom link before the 'Lost your password?' link. I'm currently using a function that h...
[ { "answer_id": 99256, "author": "David Senkus", "author_id": 30639, "author_profile": "https://wordpress.stackexchange.com/users/30639", "pm_score": 1, "selected": false, "text": "<p>There are few login form hooks which could be useful to you: </p>\n\n<pre><code>login_form AND login_foot...
2013/05/13
[ "https://wordpress.stackexchange.com/questions/99251", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32775/" ]
<http://redrokk.com/wordpress/wp-content/uploads/2012/07/blank_wordpress_login_form1.png> I want to add a custom link before the 'Lost your password?' link. I'm currently using a function that has some css to style my wordpress login page(I don't have a separate page for the login page). Any thoughts on how to do this...
Well, you can add link after lost your password, but I don't think you can add link before lost your password link unless you design your own login page. ``` function hook_lost_your_password ( $text ) { if ($text == 'Lost your password?'){ $text .= '<br /><a href="http://codebing.com">Visit Code Bi...
99,265
<p>I'm trying to display the 5 best rated posts of the last week (7 days) on my website, however I can't seem to figure out how to display them.</p> <p>Here's what I've achieved so far but it doesn't seem to work:</p> <pre><code>&lt;?php $slider_query = new WP_Query('posts_per_page=5&amp;cat=3&amp;orderby=highest_rat...
[ { "answer_id": 99267, "author": "RRikesh", "author_id": 17305, "author_profile": "https://wordpress.stackexchange.com/users/17305", "pm_score": 0, "selected": false, "text": "<p>From the <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query#Time_Parameters\" rel=\"nofollow\"><cod...
2013/05/13
[ "https://wordpress.stackexchange.com/questions/99265", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22588/" ]
I'm trying to display the 5 best rated posts of the last week (7 days) on my website, however I can't seem to figure out how to display them. Here's what I've achieved so far but it doesn't seem to work: ``` <?php $slider_query = new WP_Query('posts_per_page=5&cat=3&orderby=highest_rated&order=desc'); ?> <?php $myl...
In addition to birgire's solution, as of WordPress 3.7, you can use [Date parameters](http://codex.wordpress.org/Class_Reference/WP_Query). Your arguments would look like this to filter posts from the last 7 days: ``` $args = array( 'post_type' => 'post', 'post_status' => 'publish', 'orderby' => 'date', ...
99,287
<p>I have a question about the comment numbers in a post... For now, I can output the total number of a comment inside a post outside the loop. That's cool enough, but I want to get <strong>show the comment number/amount of a post PER DAY</strong>. So let's say I have a post and people are commenting 10 times today... ...
[ { "answer_id": 99290, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 3, "selected": true, "text": "<p>There is no argument to restrict a comment query directly to a given date. You have to filter the query later:</p>\n\n<...
2013/05/13
[ "https://wordpress.stackexchange.com/questions/99287", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32731/" ]
I have a question about the comment numbers in a post... For now, I can output the total number of a comment inside a post outside the loop. That's cool enough, but I want to get **show the comment number/amount of a post PER DAY**. So let's say I have a post and people are commenting 10 times today... Than, I want to ...
There is no argument to restrict a comment query directly to a given date. You have to filter the query later: ``` /** * Get the number of comments for a post today. * * @param int $post_id * @return int */ function t5_count_comments_today( $post_id = NULL ) { if ( NULL === $post_id ) $post_id = get_...
99,295
<p>I am trying to use the below code snippet to display an image and then wrap it in a link to a specific term archive page. In this case, I have a custom taxonomy (Series) with a few different terms. The variable $series outputs the Term Object, therefore I want to use the get_term_link function to get the URL to the ...
[ { "answer_id": 99298, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 3, "selected": true, "text": "<p>That field can return multiple term objects depending on how you've got it configured, so I'll guess that <code>$ser...
2013/05/13
[ "https://wordpress.stackexchange.com/questions/99295", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23492/" ]
I am trying to use the below code snippet to display an image and then wrap it in a link to a specific term archive page. In this case, I have a custom taxonomy (Series) with a few different terms. The variable $series outputs the Term Object, therefore I want to use the get\_term\_link function to get the URL to the t...
That field can return multiple term objects depending on how you've got it configured, so I'll guess that `$series` in this case is an array containing a single element, which contains your term object. Try inspecting the contents of series: ``` print_r( $series ); ``` You'll probably see something like: ``` Array ...
99,297
<p>I would like to offer my visitors the option to download the entire photo gallery (displayed on dedicated [gallery] pages) as a ZIP file displayed at the bottom of each gallery page. - The full-sized image will have to be included.</p> <p>David Walsh has given some code in his post <a href="http://davidwalsh.name/c...
[ { "answer_id": 99299, "author": "Ralf912", "author_id": 16589, "author_profile": "https://wordpress.stackexchange.com/users/16589", "pm_score": 5, "selected": true, "text": "<p>First you have to get the images. How to get all images of a gallery is described <a href=\"https://stackoverfl...
2013/05/13
[ "https://wordpress.stackexchange.com/questions/99297", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25635/" ]
I would like to offer my visitors the option to download the entire photo gallery (displayed on dedicated [gallery] pages) as a ZIP file displayed at the bottom of each gallery page. - The full-sized image will have to be included. David Walsh has given some code in his post [here](http://davidwalsh.name/create-zip-ph...
First you have to get the images. How to get all images of a gallery is described [here](https://stackoverflow.com/a/9171020/1055394). WordPress uses two classes for unzipping files. The PHP bilt in `ZipArchive()` (usage see David Walsh). And [PclZip](http://www.phpconcept.net/pclzip/), you can found this class in `wp...
99,307
<p>I am pretty much learning by doing a custom theme from scratch (not a child theme), and have had much trouble with permalinks.</p> <p>In the permalinks settings page on the wp-admin, if I put any option either than the default linking system, all my links result in 404 page not found errors.</p> <p>I'm not sure if...
[ { "answer_id": 99299, "author": "Ralf912", "author_id": 16589, "author_profile": "https://wordpress.stackexchange.com/users/16589", "pm_score": 5, "selected": true, "text": "<p>First you have to get the images. How to get all images of a gallery is described <a href=\"https://stackoverfl...
2013/05/13
[ "https://wordpress.stackexchange.com/questions/99307", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31421/" ]
I am pretty much learning by doing a custom theme from scratch (not a child theme), and have had much trouble with permalinks. In the permalinks settings page on the wp-admin, if I put any option either than the default linking system, all my links result in 404 page not found errors. I'm not sure if this even exists...
First you have to get the images. How to get all images of a gallery is described [here](https://stackoverflow.com/a/9171020/1055394). WordPress uses two classes for unzipping files. The PHP bilt in `ZipArchive()` (usage see David Walsh). And [PclZip](http://www.phpconcept.net/pclzip/), you can found this class in `wp...
99,324
<p>I want to display in the front page of my theme the first most recent post in the header and then continuing the loop in the main content section starting from the second to post and so on, how can i achieve this?</p>
[ { "answer_id": 99326, "author": "JMau", "author_id": 31376, "author_profile": "https://wordpress.stackexchange.com/users/31376", "pm_score": 0, "selected": false, "text": "<p>You just have to set a new query and play with the parameter offset <a href=\"http://codex.wordpress.org/Class_Re...
2013/05/13
[ "https://wordpress.stackexchange.com/questions/99324", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32793/" ]
I want to display in the front page of my theme the first most recent post in the header and then continuing the loop in the main content section starting from the second to post and so on, how can i achieve this?
Calling `the_post()` is what advances the internal `current_post` counter that `have_posts()` checks the value of within the loop. With this in mind, you can call `the_post()` once outside the loop and use any template tags you wish, then run the loop as normal and it will pick up and continue from the second post. `...
99,344
<p>I am using <strong>custom post_type</strong> and <strong>inside the loop</strong> I echo get_delete_post_link but there is nothing echoing. </p> <pre><code>&lt;?php $wpquery = new WP_Query('post_type=myposts'); if( $wpquery-&gt;have_posts() ) { while ($wpquery-&gt;have_posts()) : $wpquery-&gt;the_post(); ...
[ { "answer_id": 99350, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 1, "selected": false, "text": "<p>All I can see that might cause this <a href=\"http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/l...
2013/05/14
[ "https://wordpress.stackexchange.com/questions/99344", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32801/" ]
I am using **custom post\_type** and **inside the loop** I echo get\_delete\_post\_link but there is nothing echoing. ``` <?php $wpquery = new WP_Query('post_type=myposts'); if( $wpquery->have_posts() ) { while ($wpquery->have_posts()) : $wpquery->the_post(); $id = get_the_ID(); //just a test...
Is the user logged in and is allowed to delete posts of this post type? There are three checks inside the `get_delete_post_link` function before anything starts happening: ``` if ( !$post = get_post( $id ) ) return; $post_type_object = get_post_type_object( $post->post_type ); if ( !$post_type_object ) return...
99,361
<p>I have a portion of a page template that is conditional upon the following <code>elseif</code></p> <pre><code>&lt;?php elseif( isset( $wp_query-&gt;query_vars['details'] ) &amp;&amp; $wp_query-&gt;query_vars['details'] == 'child': </code></pre> <p>Is there a way to exclude a queries from a particular page slug? I...
[ { "answer_id": 99383, "author": "Angela", "author_id": 28229, "author_profile": "https://wordpress.stackexchange.com/users/28229", "pm_score": 0, "selected": false, "text": "<p>WP_Query does not exclude post objects based on title (using the post__not_in => array() parameter), rather bas...
2013/05/14
[ "https://wordpress.stackexchange.com/questions/99361", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5295/" ]
I have a portion of a page template that is conditional upon the following `elseif` ``` <?php elseif( isset( $wp_query->query_vars['details'] ) && $wp_query->query_vars['details'] == 'child': ``` Is there a way to exclude a queries from a particular page slug? I would like to exclude queries coming from a page call...
I ended using the [`wp-get-referer`](http://codex.wordpress.org/Function_Reference/wp_get_referer) function in a conditional. Here's the resulting code: ``` <?php $ref1 = parse_url(wp_get_referer()); //getting the referring URL if($ref1["path"]=='/services-we-provide/') :?> //Do stuff <?php else: ?> //...
99,371
<p>I'm trying the following (it's a sidebar widget in the Single New template):</p> <pre><code> &lt;ul class="featured-jobs"&gt; &lt;?php $postid = $post-&gt;ID; $categories = get_the_category($post-&gt;ID); ?&gt; &lt;h2&gt;&lt;?php echo $postid; ?&gt;&lt;/h2&gt; &lt;h2&gt;&lt;?php echo $categories; ?...
[ { "answer_id": 99374, "author": "ahmetlutfu", "author_id": 25086, "author_profile": "https://wordpress.stackexchange.com/users/25086", "pm_score": 3, "selected": true, "text": "<p>You must export all table beginning with your WordPress prefix. </p>\n\n<ol>\n<li>Open your phpmyadmin panel...
2013/05/14
[ "https://wordpress.stackexchange.com/questions/99371", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/781/" ]
I'm trying the following (it's a sidebar widget in the Single New template): ``` <ul class="featured-jobs"> <?php $postid = $post->ID; $categories = get_the_category($post->ID); ?> <h2><?php echo $postid; ?></h2> <h2><?php echo $categories; ?></h2> <?php // Create and run custom loop $args=arra...
You must export all table beginning with your WordPress prefix. 1. Open your phpmyadmin panel. 2. Then open your wordpress database. 3. Click "export" from top menu. 4. Select "Export Method:" as custom. 5. Select your all tables beginning your prefix. 6. Then go to bottom of page click "go". You got your SQL file. ...
99,378
<p>I've got these custom post types (CPT) and meta boxes:</p> <ul> <li>Movies (CPT) <ul> <li>Genre (Meta box)</li> </ul></li> <li>Genres (CPT)</li> </ul> <p>If one movie is called Die hard then I want the permalink to be: /genres/action/die-hard</p> <p>This is easily fixed by setting the movie-CPT to 'rewrite' => fa...
[ { "answer_id": 99381, "author": "Angela", "author_id": 28229, "author_profile": "https://wordpress.stackexchange.com/users/28229", "pm_score": 1, "selected": false, "text": "<p>I think you're taking the wrong approach in terms of data structure. You should create a custom taxonomy called...
2013/05/14
[ "https://wordpress.stackexchange.com/questions/99378", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1936/" ]
I've got these custom post types (CPT) and meta boxes: * Movies (CPT) + Genre (Meta box) * Genres (CPT) If one movie is called Die hard then I want the permalink to be: /genres/action/die-hard This is easily fixed by setting the movie-CPT to 'rewrite' => false and use this code instead: ``` add_action('init', 'rb_...
It sounds like you're very close here and your only remaining issue is that your permalinks for genres and movies collide. ``` 'movies' CPT permalink /genres/%custom field meta box value%/%movie%/ 'genres' CPT permalink /genres/%genre%/ ``` The issue here is using the `add_permastruct`. When it creates the rules fo...
99,406
<p>I am using Dzonia Lite theme in my website. My front page shows all the latest posts. I am getting an excerpt at the end of each post.</p> <p>Could anyone suggest me how to remove that excerpt at the end of the post.</p> <h1>Below is the code that I have in my template file</h1> <pre><code>&lt;div class=&quot;post_...
[ { "answer_id": 99381, "author": "Angela", "author_id": 28229, "author_profile": "https://wordpress.stackexchange.com/users/28229", "pm_score": 1, "selected": false, "text": "<p>I think you're taking the wrong approach in terms of data structure. You should create a custom taxonomy called...
2013/05/14
[ "https://wordpress.stackexchange.com/questions/99406", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23712/" ]
I am using Dzonia Lite theme in my website. My front page shows all the latest posts. I am getting an excerpt at the end of each post. Could anyone suggest me how to remove that excerpt at the end of the post. Below is the code that I have in my template file ================================================= ``` <di...
It sounds like you're very close here and your only remaining issue is that your permalinks for genres and movies collide. ``` 'movies' CPT permalink /genres/%custom field meta box value%/%movie%/ 'genres' CPT permalink /genres/%genre%/ ``` The issue here is using the `add_permastruct`. When it creates the rules fo...