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
42,641
<p>ok this is my first time to include jQuery into wordpress and it has taken me the 2 full days trying to figure this out. No matter how many articles I read I cannot find a perfect example.</p> <p>Ok so this is my plugin file... very simple.</p> <pre><code>&lt;?php /* Plugin Name: jQuery Include Test Pl...
[ { "answer_id": 42642, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 4, "selected": true, "text": "<p>Your jQuery is wrong. what you want is <code>jQuery(docu....</code> not <code>$jQuery(docu...</code>.</p>\n\n<...
2012/02/17
[ "https://wordpress.stackexchange.com/questions/42641", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12918/" ]
ok this is my first time to include jQuery into wordpress and it has taken me the 2 full days trying to figure this out. No matter how many articles I read I cannot find a perfect example. Ok so this is my plugin file... very simple. ``` <?php /* Plugin Name: jQuery Include Test Plugin URI: http://jquery....
Your jQuery is wrong. what you want is `jQuery(docu....` not `$jQuery(docu...`. You should try to make sure the components work individually before you put them together (within reason of course), it will make troubleshooting MUCH easier for you.
42,647
<p>I have an existing website with html, css, js, and image files that I am trying to convert over to wordpress. </p> <p>I installed a clean local install using mamp on my hard drive and created a new child theme folder that references the twenty eleven theme. My style.css, header.php, footer.php, and index.php files ...
[ { "answer_id": 42648, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 3, "selected": true, "text": "<p>Theme/Parent Theme/Child Theme usage is irrelevant here. <em>Content</em> is not added via <em>Theme templat...
2012/02/17
[ "https://wordpress.stackexchange.com/questions/42647", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13230/" ]
I have an existing website with html, css, js, and image files that I am trying to convert over to wordpress. I installed a clean local install using mamp on my hard drive and created a new child theme folder that references the twenty eleven theme. My style.css, header.php, footer.php, and index.php files are custom...
Theme/Parent Theme/Child Theme usage is irrelevant here. *Content* is not added via *Theme template file*, no matter what Theme you use. Go to `Dashboard -> Pages`, and add *new **static Pages*** for each of your site's pages. WordPress will generate them, and the Theme will display them. ### Edit > > ok so I figure...
42,650
<p>I am using EditFlow's "custom status" feature for an event calendar plugin I am writing for a client.</p> <p>I've created a status called "previous events", when a date has happened the events post_status goes from "publish" to "previous events", as they would like to display previous events.</p> <p>The issue I am...
[ { "answer_id": 44029, "author": "Natebot", "author_id": 8691, "author_profile": "https://wordpress.stackexchange.com/users/8691", "pm_score": 2, "selected": false, "text": "<p>I have been looking to do something like that with EditFlow, where a custom status will determine if the post sh...
2012/02/17
[ "https://wordpress.stackexchange.com/questions/42650", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13232/" ]
I am using EditFlow's "custom status" feature for an event calendar plugin I am writing for a client. I've created a status called "previous events", when a date has happened the events post\_status goes from "publish" to "previous events", as they would like to display previous events. The issue I am facing is that ...
I have been looking to do something like that with EditFlow, where a custom status will determine if the post shows up on the homepage via a get\_posts() query. ``` $promoted_posts = get_posts( array( 'post_status' => 'promoted' ) ); ``` That works, but it looks like I'll need to filter the WP Query on the single pa...
42,652
<p>I'm not sure why I haven't been able to find this, but does anyone know how to get the input of the TinyMCE editor? I am using it in the front end and want to be able to save whatever the user has typed into the TinyMCE to a database but cannot find the best way to capture that value.</p> <p>The two solutions that ...
[ { "answer_id": 42729, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 6, "selected": true, "text": "<p>Ok apparently WordPress keeps track of what kind of editor (visual or html) is active as a class which is adde...
2012/02/17
[ "https://wordpress.stackexchange.com/questions/42652", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13233/" ]
I'm not sure why I haven't been able to find this, but does anyone know how to get the input of the TinyMCE editor? I am using it in the front end and want to be able to save whatever the user has typed into the TinyMCE to a database but cannot find the best way to capture that value. The two solutions that I've imple...
Ok apparently WordPress keeps track of what kind of editor (visual or html) is active as a class which is added to the content wrapper so here is a solution that will get you the latest content in the editor ``` function get_tinymce_content(){ if (jQuery("#wp-content-wrap").hasClass("tmce-active")){ return...
42,661
<p>Since I posted on their forum and I didn't got any answer, here I am, asking the same question again. So:</p> <p>I made a script that add the posibility to add an image and change the order for the terms of a custom taxonomy (called itinerary).</p> <p>So i use this way of getting each term, one by one (there are o...
[ { "answer_id": 42689, "author": "Ionut Staicu", "author_id": 223, "author_profile": "https://wordpress.stackexchange.com/users/223", "pm_score": 4, "selected": true, "text": "<p>Actually there is already in their API something for this:</p>\n\n<pre><code>icl_object_id(ID, custom_taxonomy...
2012/02/17
[ "https://wordpress.stackexchange.com/questions/42661", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/223/" ]
Since I posted on their forum and I didn't got any answer, here I am, asking the same question again. So: I made a script that add the posibility to add an image and change the order for the terms of a custom taxonomy (called itinerary). So i use this way of getting each term, one by one (there are only up to 10 term...
Actually there is already in their API something for this: ``` icl_object_id(ID, custom_taxonomy_name, return_original_if_missing,language_code) ``` Works like a charm. More read on this : [Language Dependent IDs](http://wpml.org/documentation/support/creating-multilingual-wordpress-themes/language-dependent-ids/)
42,694
<p>I would like to run a filter on post content after it has been created or updated.</p> <p>I would like this to occur after the user has submitted the post, as it may be a bit of a lengthy process (a find/replace to search for glossary terms and replace them with links).</p> <p>What's the most efficient and reliabl...
[ { "answer_id": 42702, "author": "Kyle", "author_id": 12476, "author_profile": "https://wordpress.stackexchange.com/users/12476", "pm_score": 0, "selected": false, "text": "<p>Would the save_post action work for you?</p>\n\n<pre><code>&lt;?php\nadd_action( 'save_post', 'wp_save_post' );\n...
2012/02/17
[ "https://wordpress.stackexchange.com/questions/42694", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6344/" ]
I would like to run a filter on post content after it has been created or updated. I would like this to occur after the user has submitted the post, as it may be a bit of a lengthy process (a find/replace to search for glossary terms and replace them with links). What's the most efficient and reliable way to achieve ...
Alright, here's some code I just whipped up. Completely untested, just wrote it right off the cuff...so don't expect it to work 100% when you drop it in, but the core concept is there, as is a decent amount of the legwork ``` add_action( 'my_filter_posts_content', 'my_filter_content' ); add_action( 'save_post', 'my_se...
42,701
<p>How can I hook the wp_list_pages function so that it reads a value of a custom field and displays it instead of displaying the page title?</p>
[ { "answer_id": 42703, "author": "Zack", "author_id": 2322, "author_profile": "https://wordpress.stackexchange.com/users/2322", "pm_score": 3, "selected": true, "text": "<p>A quick Google Search came up with <a href=\"http://adambrown.info/p/wp_hooks/hook/wp_list_pages\" rel=\"nofollow\">...
2012/02/17
[ "https://wordpress.stackexchange.com/questions/42701", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8979/" ]
How can I hook the wp\_list\_pages function so that it reads a value of a custom field and displays it instead of displaying the page title?
A quick Google Search came up with [this](http://adambrown.info/p/wp_hooks/hook/wp_list_pages) [Source](http://adambrown.info/p/wp_hooks/hook/wp_list_pages?version=3.3&file=wp-includes/post-template.php) Try the following: ``` function wp_list_pages_filter($output) { // modify $output here, it's a string of <li>...
42,743
<p>I'm using the_excerpt on my index page. I'm also using a dropcap shortcode at the beginning of each of my posts. On the index page, the posts will not display the letter with the dropcap shortcode around it. If my post beings with the word &quot;Dog&quot; the index page displays &quot;og&quot;. How do I get shortco...
[ { "answer_id": 42745, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 5, "selected": true, "text": "<p>Paste this in your theme's functions.php file</p>\n\n<pre><code>add_filter( 'the_excerpt', 'shortcode_unautop'...
2012/02/18
[ "https://wordpress.stackexchange.com/questions/42743", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12978/" ]
I'm using the\_excerpt on my index page. I'm also using a dropcap shortcode at the beginning of each of my posts. On the index page, the posts will not display the letter with the dropcap shortcode around it. If my post beings with the word "Dog" the index page displays "og". How do I get shortcodes to work when using ...
Paste this in your theme's functions.php file ``` add_filter( 'the_excerpt', 'shortcode_unautop'); add_filter( 'the_excerpt', 'do_shortcode'); ```
42,761
<p>I have a WP 3.3.0 site running in production. (version.php says <code>$wp_version = '3.3';</code>)</p> <p>I have a main menu using WP's built-in functionality. I use</p> <pre><code>wp_nav_menu(array( 'container_class' =&gt; 'menu-header', 'theme_location' =&gt; 'primary')); </code></pre> <p>I made a copy of that...
[ { "answer_id": 42784, "author": "helenhousandi", "author_id": 2226, "author_profile": "https://wordpress.stackexchange.com/users/2226", "pm_score": 3, "selected": true, "text": "<p>The markup above looks like a menu was not actually assigned to the area and is using the <code>wp_list_pag...
2012/02/18
[ "https://wordpress.stackexchange.com/questions/42761", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2161/" ]
I have a WP 3.3.0 site running in production. (version.php says `$wp_version = '3.3';`) I have a main menu using WP's built-in functionality. I use ``` wp_nav_menu(array( 'container_class' => 'menu-header', 'theme_location' => 'primary')); ``` I made a copy of that site, installed it in a different location, and r...
The markup above looks like a menu was not actually assigned to the area and is using the `wp_list_pages()` fallback instead. Point release changes (e.g. 3.3 to 3.3.1) are always going to be for major bugfixes and/or security, never for changes in functionality.
42,777
<p>I'm trying to migrate my self-hosted WP blog to WordPress.com, images included.</p> <p>Originally images were hosted on various image-hosting websites, but I've used <a href="http://wordpress.org/extend/plugins/add-linked-images-to-gallery-v01/" rel="nofollow">this plugin</a> to cache and upload them to my self-hos...
[ { "answer_id": 42802, "author": "markratledge", "author_id": 268, "author_profile": "https://wordpress.stackexchange.com/users/268", "pm_score": 0, "selected": false, "text": "<p>At .com, you can't use plugins or access the database to run queries to change the URLs. So yes, export the X...
2012/02/18
[ "https://wordpress.stackexchange.com/questions/42777", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13274/" ]
I'm trying to migrate my self-hosted WP blog to WordPress.com, images included. Originally images were hosted on various image-hosting websites, but I've used [this plugin](http://wordpress.org/extend/plugins/add-linked-images-to-gallery-v01/) to cache and upload them to my self-hosted WP media library. Now posts have...
I eventually used [this plugin](http://wordpress.org/extend/plugins/add-linked-images-to-gallery-v01/) to download and cache all images locally, and replace all links to the local ones.
42,796
<p>Trying to customize Twenty Elevent theme it would be super useful for me as a beginner to see which templates rendered which pages / parts of the pages. Is there a plugin or manual way to achieve that? The easiest thing that comes to mind would be to add HTML comments to each and every template file but maybe some p...
[ { "answer_id": 42797, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 1, "selected": false, "text": "<p>You can enable debugging and install the debug bar, it won't tell you which specific areas of a template are used ,...
2012/02/19
[ "https://wordpress.stackexchange.com/questions/42796", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12248/" ]
Trying to customize Twenty Elevent theme it would be super useful for me as a beginner to see which templates rendered which pages / parts of the pages. Is there a plugin or manual way to achieve that? The easiest thing that comes to mind would be to add HTML comments to each and every template file but maybe some plug...
Here is something i use when developing themes: ``` add_filter( 'template_include', 'store_template_file', 999 ); function store_template_file( $template ){ $GLOBALS['current_theme_file'] = basename($template); return $template; } add_action('wp_footer','print_theme_file'); function print_theme_file(){ if...
42,800
<p>In a single post template I am trying to output some header text in a <code>&lt;div&gt;</code> and display links to related posts in a <code>&lt;ul&gt;</code> if related posts exist (based on tags). If there are no posts, nothing should be displayed. <code>$idspost[] = $post-&gt;ID</code> gets the posts which should...
[ { "answer_id": 42797, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 1, "selected": false, "text": "<p>You can enable debugging and install the debug bar, it won't tell you which specific areas of a template are used ,...
2012/02/19
[ "https://wordpress.stackexchange.com/questions/42800", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11022/" ]
In a single post template I am trying to output some header text in a `<div>` and display links to related posts in a `<ul>` if related posts exist (based on tags). If there are no posts, nothing should be displayed. `$idspost[] = $post->ID` gets the posts which should be displayed. The loop is one of a series of loops...
Here is something i use when developing themes: ``` add_filter( 'template_include', 'store_template_file', 999 ); function store_template_file( $template ){ $GLOBALS['current_theme_file'] = basename($template); return $template; } add_action('wp_footer','print_theme_file'); function print_theme_file(){ if...
42,836
<p>I'm changing a menu from a loop with <code>query_posts</code> to a "custom menu" using <code>wp_get_nav_menu_items</code>, but I can't seem to retrieve the <code>post_thumbnail</code>.</p> <p>The original code I had (snippet):</p> <pre><code>&lt;?php query_posts($args); if (have_posts()) : while (have_posts()) : t...
[ { "answer_id": 42797, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 1, "selected": false, "text": "<p>You can enable debugging and install the debug bar, it won't tell you which specific areas of a template are used ,...
2012/02/19
[ "https://wordpress.stackexchange.com/questions/42836", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10497/" ]
I'm changing a menu from a loop with `query_posts` to a "custom menu" using `wp_get_nav_menu_items`, but I can't seem to retrieve the `post_thumbnail`. The original code I had (snippet): ``` <?php query_posts($args); if (have_posts()) : while (have_posts()) : the_post(); $image = wp_get_attachment_image_src(get_p...
Here is something i use when developing themes: ``` add_filter( 'template_include', 'store_template_file', 999 ); function store_template_file( $template ){ $GLOBALS['current_theme_file'] = basename($template); return $template; } add_action('wp_footer','print_theme_file'); function print_theme_file(){ if...
42,839
<p>I can't find any info on this anywhere but i'm sure iv'e seen it done before.</p> <p>I would like to have a user taken to the settings page for my plugin after install, so either auto-redirected or change the "back to plugins" link to a custom link.</p> <p>Thanks in advance </p> <p><strong>SOLVED</strong></p> <p...
[ { "answer_id": 42841, "author": "Zack", "author_id": 2322, "author_profile": "https://wordpress.stackexchange.com/users/2322", "pm_score": 4, "selected": true, "text": "<p>Register an activation hook and then redirect the user's browser when you're done installing your plugin.</p>\n\n<pr...
2012/02/19
[ "https://wordpress.stackexchange.com/questions/42839", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12364/" ]
I can't find any info on this anywhere but i'm sure iv'e seen it done before. I would like to have a user taken to the settings page for my plugin after install, so either auto-redirected or change the "back to plugins" link to a custom link. Thanks in advance **SOLVED** ``` function myplugin_activate() { ...
Register an activation hook and then redirect the user's browser when you're done installing your plugin. ``` function myplugin_activate() { // TODO: Install your plugin here. // I don't know of any other redirect function, so this'll have to do. wp_redirect(admin_url('options-general.php?page=myplugi...
42,843
<p>I have a index.php with a featured post and a number of other posts and the standard wp_pagenavi at the bottom.</p> <p>I'm using the 2 loops from the <a href="http://codex.wordpress.org/The_Loop" rel="nofollow">wordpress codex</a> like this:</p> <pre><code>&lt;?php $my_query = new WP_Query('category_name=featured&...
[ { "answer_id": 42844, "author": "Matthew Boynes", "author_id": 12324, "author_profile": "https://wordpress.stackexchange.com/users/12324", "pm_score": 0, "selected": false, "text": "<p><code>is_paged</code> is just a boolean function for if the list has multiple pages or not.</p>\n\n<p>W...
2012/02/19
[ "https://wordpress.stackexchange.com/questions/42843", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5352/" ]
I have a index.php with a featured post and a number of other posts and the standard wp\_pagenavi at the bottom. I'm using the 2 loops from the [wordpress codex](http://codex.wordpress.org/The_Loop) like this: ``` <?php $my_query = new WP_Query('category_name=featured&posts_per_page=1'); while ($my_query->have_posts(...
In short no - the template used is based on the query, and when paginating you are essentially repeating the same query, but for a different page. In general the template will be the same. `archive.php` *can* be used for most queries, but often preferable templates exist (e.g. category templates, tag templates, autho...
42,853
<p>I wrote my first ShortCode in a file called: myShortCodes.php. </p> <p>Does the add_shortcode go in the same PHP file as the ShortCode itself? Where do I upload it? How does WordPress know to look in my file? </p> <p>I don't have to modify \wp_includes\shortcodes.php do I? </p> <p>So far I have tried uploading m...
[ { "answer_id": 42854, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 0, "selected": false, "text": "<p>Your all your shortcode functions should either go in <code>functions.php</code> or a plugin file or be <a hr...
2012/02/19
[ "https://wordpress.stackexchange.com/questions/42853", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2550/" ]
I wrote my first ShortCode in a file called: myShortCodes.php. Does the add\_shortcode go in the same PHP file as the ShortCode itself? Where do I upload it? How does WordPress know to look in my file? I don't have to modify \wp\_includes\shortcodes.php do I? So far I have tried uploading myShortCodes.php to 1...
In general, special theme functionality (including shortcodes) should be placed in your theme's `functions.php` file, which is in the root of your **theme** folder. If the code is less than a few dozen lines, it probably won't be worth creating a separate file (unless you just really want to organize your code that way...
42,874
<p>I have stored an array of post IDs and I would like to list the posts as links, meaning I need to get the title and permalink for the post ID - $id. The list should be echoed out by the following if condition, which means I somehow have to replace $id with the permalink and title. At the moment the code merely lists...
[ { "answer_id": 42875, "author": "Evan Yeung", "author_id": 1878, "author_profile": "https://wordpress.stackexchange.com/users/1878", "pm_score": 6, "selected": true, "text": "<pre><code>&lt;?php\nif(count($related)) {\n echo \"&lt;div&gt;Read More&lt;ul&gt;\";\n foreach($related as...
2012/02/20
[ "https://wordpress.stackexchange.com/questions/42874", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11022/" ]
I have stored an array of post IDs and I would like to list the posts as links, meaning I need to get the title and permalink for the post ID - $id. The list should be echoed out by the following if condition, which means I somehow have to replace $id with the permalink and title. At the moment the code merely lists th...
``` <?php if(count($related)) { echo "<div>Read More<ul>"; foreach($related as $id) { echo '<li><a href="'.get_permalink( $id ).'">'.get_the_title( $id ).'</a></li>';     }     echo "</ul></div>";   } ?>   ```
42,882
<p>In a plugin class I want to provide simple fields for public data: email, phone number, Twitter etc. The list can be extended.</p> <p>See the <a href="https://github.com/toscho/Public-Contact-Data" rel="noreferrer">plugin Public Contact Data</a> on GitHub for details.</p> <p>To keep the usage simple, I also want t...
[ { "answer_id": 42906, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 3, "selected": true, "text": "<p><em>This is untested</em>, but the callback function is provided with an array of arguments, <code>$args</...
2012/02/20
[ "https://wordpress.stackexchange.com/questions/42882", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73/" ]
In a plugin class I want to provide simple fields for public data: email, phone number, Twitter etc. The list can be extended. See the [plugin Public Contact Data](https://github.com/toscho/Public-Contact-Data) on GitHub for details. To keep the usage simple, I also want to offer shortcodes which are easy to type: *...
*This is untested*, but the callback function is provided with an array of arguments, `$args` which give (if any) the paramters provided with the shortocode. The zeroth entry *sometimes* contains the name of the shortcode used (e.g. `public_email`). By sometimes I mean... > > The zeroeth entry of the attributes array...
42,883
<p>First question and first commercial plugin. Woohoo!</p> <p>I'm trying to create a dashboard widget that leverages user input and a predefined URL structure to create an outbound link that sends the user to his/her desired destination. This is basically a hack created so that users on a blogging network can query a...
[ { "answer_id": 42909, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 0, "selected": false, "text": "<p>You want <a href=\"http://codex.wordpress.org/Function_Reference/add_query_arg\" rel=\"nofollow\"><code>a...
2012/02/20
[ "https://wordpress.stackexchange.com/questions/42883", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13306/" ]
First question and first commercial plugin. Woohoo! I'm trying to create a dashboard widget that leverages user input and a predefined URL structure to create an outbound link that sends the user to his/her desired destination. This is basically a hack created so that users on a blogging network can query another Word...
If you set the action of the form to the page which you want to do the processing, it will redirect to that page as well as setting all the `$_GET` and `$_POST` variables up for easy access.
42,891
<p>I am currently trying to create a wordpress search function that shows live results underneath the search bar. There is an example on the <a href="http://data.worldbank.org/frontpage" rel="noreferrer">World Bank</a> website (screens below). I'm not looking for an autofill like you would find on Google.com which comp...
[ { "answer_id": 42898, "author": "Webord", "author_id": 454, "author_profile": "https://wordpress.stackexchange.com/users/454", "pm_score": 0, "selected": false, "text": "<p>You must do it using Ajax of course, but here there is a problem. Since WordPress uses MySQL, you might over stress...
2012/02/20
[ "https://wordpress.stackexchange.com/questions/42891", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6423/" ]
I am currently trying to create a wordpress search function that shows live results underneath the search bar. There is an example on the [World Bank](http://data.worldbank.org/frontpage) website (screens below). I'm not looking for an autofill like you would find on Google.com which completes words you type, rather I ...
The following uses jQuery UI Autocomplete, which has been included in WordPress since 3.3. (I've borrowed the format from **@Rarst** :D). It's still not precisely what you're after, but gives you a good starting point. The following uses a the basic jQuery UI styling, but you can [use the one that's currently worked o...
42,896
<p>The code you see below only works sometimes. I'm no pro on PHP so can anyone help me improve this code? I use it in my functions-php file in my WordPress mu setup.</p> <p>The biggest problem is that it won't remove duplicate fileds. i.e. if I have 2 custom fields named Image and one is empty I want this script to r...
[ { "answer_id": 42908, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 1, "selected": false, "text": "<p>I believe this was my solution to a previous question you had.</p>\n\n<p>I mentioned in that answer that ...
2012/02/20
[ "https://wordpress.stackexchange.com/questions/42896", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12727/" ]
The code you see below only works sometimes. I'm no pro on PHP so can anyone help me improve this code? I use it in my functions-php file in my WordPress mu setup. The biggest problem is that it won't remove duplicate fileds. i.e. if I have 2 custom fields named Image and one is empty I want this script to remove this...
I believe this was my solution to a previous question you had. I mentioned in that answer that the code didn't deal with the eventuality of a key with multiple values and only some of which are empty. The reason why is how WordPress treats [`delete_post_meta`](http://codex.wordpress.org/Function_Reference/delete_post_...
42,912
<p>I am currently using wordpress menu like this ... </p> <pre><code>$args=array('menu'=&gt;'menu', 'menu_class'=&gt;'', 'before'=&gt;'&lt;span&gt;', 'after'=&gt;'&lt;/span&gt;', 'link_before'=&gt;'', 'link_after'=&gt;'' ); wp_nav_menu($arg...
[ { "answer_id": 42914, "author": "Cristian", "author_id": 2264, "author_profile": "https://wordpress.stackexchange.com/users/2264", "pm_score": 0, "selected": false, "text": "<p>Adding links to a menu is done from the Admin area. You will find the menu editor under Appearance -> Menus.</p...
2012/02/20
[ "https://wordpress.stackexchange.com/questions/42912", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12621/" ]
I am currently using wordpress menu like this ... ``` $args=array('menu'=>'menu', 'menu_class'=>'', 'before'=>'<span>', 'after'=>'</span>', 'link_before'=>'', 'link_after'=>'' ); wp_nav_menu($args); ``` But what if want is to add a speci...
You're `_doing_it_wrong()`. When you call `wp_nav_menu()`, you should be referencing `theme_location`, **not** `menu`. The way the custom navigation menu functionality is intended to work: 1. The **Theme** registers *locations* for navigation menus to appear, via `register_nav_menus( array( 'location_slug' => 'Locati...
42,927
<p>I'm making a layout for a wordpress page.</p> <p>The layout needs to connect to a second database (both databases are in the same domain).</p> <p>But the problem is, when i execute just the file it works. But when i included inside the wordpress layout i don't get data, no errorrs, nothing</p> <p>The script is j...
[ { "answer_id": 42935, "author": "goldenapples", "author_id": 290, "author_profile": "https://wordpress.stackexchange.com/users/290", "pm_score": 4, "selected": true, "text": "<p>I don't know why the mysql_connect isn't working inside WordPress. But an easier way of doing it would be to u...
2012/02/20
[ "https://wordpress.stackexchange.com/questions/42927", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13329/" ]
I'm making a layout for a wordpress page. The layout needs to connect to a second database (both databases are in the same domain). But the problem is, when i execute just the file it works. But when i included inside the wordpress layout i don't get data, no errorrs, nothing The script is just: ``` $con = mysql_c...
I don't know why the mysql\_connect isn't working inside WordPress. But an easier way of doing it would be to use the **$wpdb** class. Try replacing your code with this: ``` $second_db = new $wpdb( 'user', 'pass', 'dbname', 'host' ); $q = $second_db->get_results( 'SELECT * FROM vars' ); var_dump( $q ); ``` and see i...
42,941
<p>I'm trying to ajaxify my Wordpress theme and I use the method <a href="http://web-profile.com.ua/wordpress/dev/ajax-in-wordpress/" rel="nofollow">described here</a> and I'm now trying get_the_content of post via functions.php. Using jQuery, when I do alert(data) I get the 'title' echo but not the content of the exis...
[ { "answer_id": 42942, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 2, "selected": false, "text": "<p><code>get_the_content()</code> must be used inside the loop, or otherwise you'll need to use <code>setup_...
2012/02/20
[ "https://wordpress.stackexchange.com/questions/42941", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7838/" ]
I'm trying to ajaxify my Wordpress theme and I use the method [described here](http://web-profile.com.ua/wordpress/dev/ajax-in-wordpress/) and I'm now trying get\_the\_content of post via functions.php. Using jQuery, when I do alert(data) I get the 'title' echo but not the content of the existing post I want (returns 0...
I got a solution [here](https://wordpress.stackexchange.com/questions/61565/trying-to-load-content-of-a-post-via-ajax) in another post I made about the same problem I had.
42,955
<p>How can I get $id variable in widget's form function? According to widget's structure I see that widget function have $args as a parameter, which will be extracted in function's body. In my case i want to use $id variable (from extracted $args) which contains current sidebar's id. How can I make 'visible' $id variab...
[ { "answer_id": 42969, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 1, "selected": false, "text": "<p>Do you search for <code>$args['widget_id']</code>? Just save it in a variable you can access in <code>form()</code> la...
2012/02/20
[ "https://wordpress.stackexchange.com/questions/42955", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13250/" ]
How can I get $id variable in widget's form function? According to widget's structure I see that widget function have $args as a parameter, which will be extracted in function's body. In my case i want to use $id variable (from extracted $args) which contains current sidebar's id. How can I make 'visible' $id variable ...
Do you search for `$args['widget_id']`? Just save it in a variable you can access in `form()` later. Look at `wp-includes/default-widgets.php` to see how widgets work. Not the best code, but it should give you some hints.
42,962
<p>I need to create a variable that can be accessed throughout my WordPress Theme template files (index.php, header.php etc..). I know function definitions go inside the <code>functions.php</code> template file (in your theme path), but there's no such thing for variables.</p> <p>For example I constantly need to retr...
[ { "answer_id": 42963, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": 4, "selected": true, "text": "<p>Apparently <code>global</code> does the trick.\nThe problem was that my variable <code>$categories</code> should ha...
2009/11/06
[ "https://wordpress.stackexchange.com/questions/42962", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I need to create a variable that can be accessed throughout my WordPress Theme template files (index.php, header.php etc..). I know function definitions go inside the `functions.php` template file (in your theme path), but there's no such thing for variables. For example I constantly need to retrieve Categories in my ...
Apparently `global` does the trick. The problem was that my variable `$categories` should have been **redefined** with a `global` in front of it, in each template I needed to use it.
42,974
<p>My goal here is to load the blogroll into my theme via ajax. But all that I can get as response is 0 (if I omit the die() line, else I get a blank response).</p> <p>Here is my code:</p> <p>js ajax:</p> <pre><code>$.ajax({ url:"http://domain.com/wp-admin/admin-ajax.php", type:'POST', data:'action=load_...
[ { "answer_id": 42963, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": 4, "selected": true, "text": "<p>Apparently <code>global</code> does the trick.\nThe problem was that my variable <code>$categories</code> should ha...
2012/02/20
[ "https://wordpress.stackexchange.com/questions/42974", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13340/" ]
My goal here is to load the blogroll into my theme via ajax. But all that I can get as response is 0 (if I omit the die() line, else I get a blank response). Here is my code: js ajax: ``` $.ajax({ url:"http://domain.com/wp-admin/admin-ajax.php", type:'POST', data:'action=load_men_blog', //dataType:'h...
Apparently `global` does the trick. The problem was that my variable `$categories` should have been **redefined** with a `global` in front of it, in each template I needed to use it.
43,014
<p>Just a simple question is it possible if yes what are the requirements of this mean i want to make a table for adding songs information in table like </p> <pre><code>link | name | date | size | moviename </code></pre> <p>is it possible if yes any idea or any suggestion thanks</p>
[ { "answer_id": 43017, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 2, "selected": false, "text": "<p>Yes, the Codex gives a great introduction in how to create your own database tables <a href=\"http://code...
2012/02/21
[ "https://wordpress.stackexchange.com/questions/43014", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9255/" ]
Just a simple question is it possible if yes what are the requirements of this mean i want to make a table for adding songs information in table like ``` link | name | date | size | moviename ``` is it possible if yes any idea or any suggestion thanks
Yes, the Codex gives a great introduction in how to create your own database tables [here](http://codex.wordpress.org/Creating_Tables_with_Plugins) :D.
43,029
<p>First, I have to admit I'm not entirely sure on how to explain this best.</p> <p>Currently I have this in my <code>header.php</code>:</p> <pre><code>&lt;?php if ( is_home() OR is_front_page() ): ?&gt; &lt;meta name="description" content="&lt;?php $options = get_option( 'schema_theme_options' ); echo $options['me...
[ { "answer_id": 43030, "author": "Tomas Buteler", "author_id": 5552, "author_profile": "https://wordpress.stackexchange.com/users/5552", "pm_score": 0, "selected": false, "text": "<p>Try this:</p>\n\n<pre><code>&lt;?php if ( (is_home() || is_front_page()) &amp;&amp; ($options = get_option...
2012/02/21
[ "https://wordpress.stackexchange.com/questions/43029", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
First, I have to admit I'm not entirely sure on how to explain this best. Currently I have this in my `header.php`: ``` <?php if ( is_home() OR is_front_page() ): ?> <meta name="description" content="<?php $options = get_option( 'schema_theme_options' ); echo $options['metadescription']; ?>"> <?php endif; ?> ``` ...
Try this: ``` <?php $options = get_option( 'schema_theme_options' ); $meta_desc = $options['metadescription']; ?> <?php if( ( is_home() || is_front_page() ) && '' !== $meta_desc ) : ?> <meta name="description" content="<?php echo $meta_desc; ?>"> <?php endif; ?> ``` It's a bit neater and a bit more foolproof tha...
43,039
<p>Thanks for replying but I still can't get it to work. Is anything wrong with this code?</p> <pre><code> &lt;?php class custom_loop extends thesis_custom_loop { function page() { if(is_page( array('career-work','happiness'))) { global $thesis_design; $thesis_design-&gt;home['body']['content']['features'] = ...
[ { "answer_id": 43030, "author": "Tomas Buteler", "author_id": 5552, "author_profile": "https://wordpress.stackexchange.com/users/5552", "pm_score": 0, "selected": false, "text": "<p>Try this:</p>\n\n<pre><code>&lt;?php if ( (is_home() || is_front_page()) &amp;&amp; ($options = get_option...
2012/02/21
[ "https://wordpress.stackexchange.com/questions/43039", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13362/" ]
Thanks for replying but I still can't get it to work. Is anything wrong with this code? ``` <?php class custom_loop extends thesis_custom_loop { function page() { if(is_page( array('career-work','happiness'))) { global $thesis_design; $thesis_design->home['body']['content']['features'] = 0; $thesis_design->d...
Try this: ``` <?php $options = get_option( 'schema_theme_options' ); $meta_desc = $options['metadescription']; ?> <?php if( ( is_home() || is_front_page() ) && '' !== $meta_desc ) : ?> <meta name="description" content="<?php echo $meta_desc; ?>"> <?php endif; ?> ``` It's a bit neater and a bit more foolproof tha...
43,049
<p>I have a few different searches on my website:</p> <ul> <li>"Species profiles" (custom post type search)</li> <li>"Glossary" (custom post type search)</li> <li>Generic, site-wide search</li> </ul> <p>Currently I'm using <code>search.php</code>; <code>$_POST["type"]</code> to determine which search has been used an...
[ { "answer_id": 43283, "author": "Rob Vermeer", "author_id": 11135, "author_profile": "https://wordpress.stackexchange.com/users/11135", "pm_score": 2, "selected": false, "text": "<p>Because you are using <code>&lt;?php $query = new WP_Query ( $args ); ?&gt;</code> the wp_query global isn...
2012/02/21
[ "https://wordpress.stackexchange.com/questions/43049", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6344/" ]
I have a few different searches on my website: * "Species profiles" (custom post type search) * "Glossary" (custom post type search) * Generic, site-wide search Currently I'm using `search.php`; `$_POST["type"]` to determine which search has been used and and `$_POST["s"]` for the query term: ``` <?php if (isset...
You don't need the type variable and other bits of custom search query code, or custom functions like the other answers. In your searchbox, instead of submitting the form to / submit it to /my\_post\_type/ instead! WordPress will handle all the rest for you automagically, with no effort involved. **What's more this m...
43,067
<p>I am trying to customize the behavior of my blog to serve a specific single post template based on the category the post is assigned to. </p> <p>I came across this filter in my parent theme which is what gave me the idea. The theme is Photo Workshop by Graph Paper Press.</p> <pre><code>//add single post template...
[ { "answer_id": 43106, "author": "Evan Mattson", "author_id": 12055, "author_profile": "https://wordpress.stackexchange.com/users/12055", "pm_score": 2, "selected": true, "text": "<p>The problem was that the <code>remove_filter</code> function wasn't working. Apparently this is not uncom...
2012/02/21
[ "https://wordpress.stackexchange.com/questions/43067", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12055/" ]
I am trying to customize the behavior of my blog to serve a specific single post template based on the category the post is assigned to. I came across this filter in my parent theme which is what gave me the idea. The theme is Photo Workshop by Graph Paper Press. ``` //add single post template depending on category ...
The problem was that the `remove_filter` function wasn't working. Apparently this is not uncommon from what I've read. I tried testing it with different priorities (1, 9, 20, 999), but there was no difference. So my filter in the child theme and the filter I was trying to remove from the parent theme both had the same...
43,076
<p>I am working on a plugin that constructs a newsletter witch uses a template with a few images. </p> <p>The images have been uploaded using the Media Library (<code>uploads/current_year/current_month/</code>) and I want to get the images URL by using the image name.</p> <p>Any way of doing this without iterating ov...
[ { "answer_id": 43096, "author": "Maor Barazany", "author_id": 2063, "author_profile": "https://wordpress.stackexchange.com/users/2063", "pm_score": 1, "selected": false, "text": "<p>I think you should run a custom mySQL query to the wp_posts table, something like - </p>\n\n<pre><code>SEL...
2012/02/21
[ "https://wordpress.stackexchange.com/questions/43076", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13375/" ]
I am working on a plugin that constructs a newsletter witch uses a template with a few images. The images have been uploaded using the Media Library (`uploads/current_year/current_month/`) and I want to get the images URL by using the image name. Any way of doing this without iterating over all the images? I have t...
[`wp_upload_dir()`](http://codex.wordpress.org/Function_Reference/wp_upload_dir) is perfect. It is the only place where you can expect write permissions. Store the attachment ID, not a path. Then you [get the image](http://codex.wordpress.org/Function_Reference/wp_get_attachment_url) with: ``` wp_get_attachment_url( ...
43,083
<p>I'm trying to limit a meta_box to posts in a specific category. I'm using this method: <a href="http://www.farinspace.com/page-specific-wordpress-meta-box/" rel="nofollow">http://www.farinspace.com/page-specific-wordpress-meta-box/</a> and it works rather well But I can't seem to get it to work with categories. Her...
[ { "answer_id": 43086, "author": "Evan Yeung", "author_id": 1878, "author_profile": "https://wordpress.stackexchange.com/users/1878", "pm_score": 1, "selected": false, "text": "<p>You might want to check out his other post: <a href=\"http://www.farinspace.com/show-hide-meta-box-by-categor...
2012/02/21
[ "https://wordpress.stackexchange.com/questions/43083", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8574/" ]
I'm trying to limit a meta\_box to posts in a specific category. I'm using this method: <http://www.farinspace.com/page-specific-wordpress-meta-box/> and it works rather well But I can't seem to get it to work with categories. Heres' my code: ``` <?php // meta box for news category add_action('admin_init','news_init'...
Just went a different way on this, didn't end up using categories.
43,134
<p>I don't want users to be able to choose to display the admin bar/toolbar when they log into wordpress. It doesn't have a function for those users.</p> <p>Instead I would like for admin users to have the toolbar shown by default and anyone else to have the toolbar hidden by default.</p> <p>I can do this with a plug...
[ { "answer_id": 43137, "author": "Matth_eu", "author_id": 13202, "author_profile": "https://wordpress.stackexchange.com/users/13202", "pm_score": 2, "selected": false, "text": "<p>Try this - change manage_options to whichever <a href=\"http://codex.wordpress.org/Roles_and_Capabilities\" r...
2012/02/22
[ "https://wordpress.stackexchange.com/questions/43134", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4529/" ]
I don't want users to be able to choose to display the admin bar/toolbar when they log into wordpress. It doesn't have a function for those users. Instead I would like for admin users to have the toolbar shown by default and anyone else to have the toolbar hidden by default. I can do this with a plugin by using css a...
To set the default to not show the admin bar on the public side at registration put the following in your theme's functions.php file (note: this will only work for new users, you'll have to manually disable it for all your current users via the Dashboard): ``` // Disable the user admin bar on public side on registrati...
43,148
<p>I have two page templates and Qtranslate installed.</p> <p>I want to choose one or another depending the language selected.</p> <p>Can I do something like this ?</p> <pre><code>if($q_config['lang'] == 'en'){ // load page-template_en.php }else{ // load page-template_de.php } </code></pre> <p>Any idea ?</p> <p>Th...
[ { "answer_id": 43151, "author": "Shane", "author_id": 10555, "author_profile": "https://wordpress.stackexchange.com/users/10555", "pm_score": 1, "selected": true, "text": "<p>It is possible using the <code>template_redirect</code> hook.</p>\n\n<p>Looks something like this :</p>\n\n<pre><...
2012/02/22
[ "https://wordpress.stackexchange.com/questions/43148", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4984/" ]
I have two page templates and Qtranslate installed. I want to choose one or another depending the language selected. Can I do something like this ? ``` if($q_config['lang'] == 'en'){ // load page-template_en.php }else{ // load page-template_de.php } ``` Any idea ? Thanks!
It is possible using the `template_redirect` hook. Looks something like this : ``` function language_redirect() { global $q_config; if( $q_config['lang'] == 'en' ) { include( get_template_directory() . '/page-template_en.php' ); exit; } else { in...
43,154
<p>Very simple question: How can I check when wp is doing an update or a publishing to a post? Because I have to check a postmeta value which could be only true if the post is actually being published and so it has not to be already present in the system. E.g. if( defined('DOING_AUTOSAVE') &amp;&amp; DOING_AUTOSAVE ) i...
[ { "answer_id": 43255, "author": "Tony", "author_id": 13078, "author_profile": "https://wordpress.stackexchange.com/users/13078", "pm_score": 2, "selected": true, "text": "<p>I avoid the problem just checking if the ID of the post is already existing in the db.</p>\n\n<pre><code>get_post(...
2012/02/22
[ "https://wordpress.stackexchange.com/questions/43154", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13078/" ]
Very simple question: How can I check when wp is doing an update or a publishing to a post? Because I have to check a postmeta value which could be only true if the post is actually being published and so it has not to be already present in the system. E.g. if( defined('DOING\_AUTOSAVE') && DOING\_AUTOSAVE ) it's defin...
I avoid the problem just checking if the ID of the post is already existing in the db. ``` get_post($id)==NULL ``` That's probably the easiest way to do what I need.
43,161
<p>I've made a custom post type, with a few accompanying widgets, and I was wondering if it is possible to show (some of) these widgets only if you're on a specific page.</p> <p>Currently I've got</p> <pre><code>function widget($args, $instance) { global $post; $links = unserialize(get_post_meta( $post-&gt;ID...
[ { "answer_id": 43162, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 1, "selected": false, "text": "<p>Instead of nuking the entire widget, you should put your conditional statements within the widget itself:</...
2012/02/22
[ "https://wordpress.stackexchange.com/questions/43161", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12817/" ]
I've made a custom post type, with a few accompanying widgets, and I was wondering if it is possible to show (some of) these widgets only if you're on a specific page. Currently I've got ``` function widget($args, $instance) { global $post; $links = unserialize(get_post_meta( $post->ID, 'links', true )); ...
Okay, I got it finally! Wouldn't have been able to without looking at the source of [Widget Logic](http://wordpress.org/extend/plugins/widget-logic/) This is how it is: First register a function to filter on `sidebar_widgets`: ``` add_filter( 'sidebars_widgets', 'my_filter_widgets', 10); ``` Then loop through all t...
43,181
<p>I found this question:</p> <p><a href="https://wordpress.stackexchange.com/questions/35196/theres-a-way-to-use-query-settax-query-in-pre-get-posts-filter">Theres a way to use $query-&gt;set(&#39;tax_query&#39; in pre_get_posts filter?</a></p> <p>which seems to indicate that yes, you can alter the taxonomy query on...
[ { "answer_id": 43345, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 4, "selected": true, "text": "<p>I could not get this to work with any combination of <code>pre_get_posts</code> or <code>parse_query</code...
2012/02/22
[ "https://wordpress.stackexchange.com/questions/43181", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6477/" ]
I found this question: [Theres a way to use $query->set('tax\_query' in pre\_get\_posts filter?](https://wordpress.stackexchange.com/questions/35196/theres-a-way-to-use-query-settax-query-in-pre-get-posts-filter) which seems to indicate that yes, you can alter the taxonomy query on taxonomy archives via pre\_get\_pos...
I could not get this to work with any combination of `pre_get_posts` or `parse_query`. I can do it relatively easily by wiping out the query object after it is made. I don't like it because then I'm running the query twice, but I'm at my wit's end with trying to be "efficient." ``` function kia_no_child_taxonomies(){ ...
43,182
<p>I have a Wordpress site translated from dansk to english using WPML. In it, I have a page which uses a custom page template to display the titles of all the posts. Sadly, it's displaying all posts twice: the original, and the translated.</p> <p>This is the code I have:</p> <pre><code>&lt;ul id="archive-list"&gt; ...
[ { "answer_id": 43205, "author": "Rob Vermeer", "author_id": 11135, "author_profile": "https://wordpress.stackexchange.com/users/11135", "pm_score": 2, "selected": false, "text": "<p>For the language filter from WPML to take effect you have to allow filters in get_posts. Default this is o...
2012/02/22
[ "https://wordpress.stackexchange.com/questions/43182", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13416/" ]
I have a Wordpress site translated from dansk to english using WPML. In it, I have a page which uses a custom page template to display the titles of all the posts. Sadly, it's displaying all posts twice: the original, and the translated. This is the code I have: ``` <ul id="archive-list"> <?php $args = array( ...
For the language filter from WPML to take effect you have to allow filters in get\_posts. Default this is off. You can add `suppress_filters=0` to your get\_posts args and it should work. See: <http://codex.wordpress.org/Template_Tags/get_posts#Parameters> ``` <ul id="archive-list"> <?php $args = array( 'suppress...
43,183
<p>I am developing an wp plugin and I am trying to get the current user.</p> <p>If i return with an error print_r($current_user) returns the needed info.</p> <p>But the plugin is activated without an error it returns NULL.</p> <p>I tried to include some wp core files such as wp-load etc but this doesn't have any eff...
[ { "answer_id": 43190, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 2, "selected": false, "text": "<p>You need to globalize <code>$current_user</code>, and then populate it via <code>get_currentuserinfo()</cod...
2012/02/22
[ "https://wordpress.stackexchange.com/questions/43183", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13417/" ]
I am developing an wp plugin and I am trying to get the current user. If i return with an error print\_r($current\_user) returns the needed info. But the plugin is activated without an error it returns NULL. I tried to include some wp core files such as wp-load etc but this doesn't have any effect. this is my code(...
You need to globalize `$current_user`, and then populate it via `get_currentuserinfo()`. See [the Codex entry for `get_currentuserinfo()`](http://codex.wordpress.org/Function_Reference/get_currentuserinfo). In the Codex-example usage: ``` <?php global $current_user; get_currentuserinfo(); ?> ``` So, try adapting you...
43,191
<p>This is either something really simple that I've orchestrated into a complex problem or it really is a complex problem.</p> <p>I've decided to use pages to display information. If I go to a page called Houston, I want to see the subpages of Houston, but also the children of those subpages. I'd like these styled in ...
[ { "answer_id": 43196, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 0, "selected": false, "text": "<p>Something like this should work:</p>\n\n<pre><code>$args = array(\n 'sort_column' =&gt; 'menu_order, post_...
2012/02/22
[ "https://wordpress.stackexchange.com/questions/43191", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13420/" ]
This is either something really simple that I've orchestrated into a complex problem or it really is a complex problem. I've decided to use pages to display information. If I go to a page called Houston, I want to see the subpages of Houston, but also the children of those subpages. I'd like these styled in a block fo...
You have so many things wrong with your code, to start WP\_Query does not have `'sort_column'` , or `'depth'` parameters. the use of `$do_not_duplicate = $post->ID;` does nothing at all and a few other things. What you need is to get the children (just the ids, no need to get the post object since you are not using an...
43,198
<p>I do not want to display the titles of videos I embed on my wordpress site. The way I've been doing this is using the embed link, inserting the iframe in the wordpress post and adding the custom Parameter "showinfo=0" to the end of the url. This has worked well, until I decided to change the design of my site. I hav...
[ { "answer_id": 43200, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 3, "selected": false, "text": "<p>No need for a plugin, You can simply use the Oembed class's <code>oembed_result</code> filter hook</p>\n\n<p>...
2012/02/22
[ "https://wordpress.stackexchange.com/questions/43198", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13390/" ]
I do not want to display the titles of videos I embed on my wordpress site. The way I've been doing this is using the embed link, inserting the iframe in the wordpress post and adding the custom Parameter "showinfo=0" to the end of the url. This has worked well, until I decided to change the design of my site. I have h...
No need for a plugin, You can simply use the Oembed class's `oembed_result` filter hook like this: ``` function Oembed_youtube_no_title($html,$url,$args){ $url_string = parse_url($url, PHP_URL_QUERY); parse_str($url_string, $id); if (isset($id['v'])) { return '<iframe width="'.$args['width'].'" he...
43,207
<p>When looking at a draft post, <code>get_the_date()</code> only seems to return today's date, not the post date, even if I have selected another date on the post edit screen.</p> <p>Is there a way to show the "actual" post date, the one I selected?</p> <p>I can see in the MySQL database that it's saved in the post_...
[ { "answer_id": 43234, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 3, "selected": false, "text": "<p>Yes, as you - so far - have no publish date.</p>\n\n<p>You could use <code>$post-&gt;post_modified</code>, which wi...
2012/02/23
[ "https://wordpress.stackexchange.com/questions/43207", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3564/" ]
When looking at a draft post, `get_the_date()` only seems to return today's date, not the post date, even if I have selected another date on the post edit screen. Is there a way to show the "actual" post date, the one I selected? I can see in the MySQL database that it's saved in the post\_date column. But, like get\...
Yes, as you - so far - have no publish date. You could use `$post->post_modified`, which will always be the date of the latest modification to the post data. --- **Debug:** Try hooking into the filter and dump both vars: ``` function date_dump_callback( $date, $d ) { echo '<pre>'; print_r( $date ); print_r( $...
43,231
<p>I have set the following custom permalink structure (for my blog):</p> <pre><code>/news/%postname% </code></pre> <p>When I browse to <code>/news</code> I was expecting for the <code>archive.php</code> template to be served up, unfortunately, I'm presented with a 404.</p> <p>My rewrite is working properly since I ...
[ { "answer_id": 44128, "author": "Luke", "author_id": 6616, "author_profile": "https://wordpress.stackexchange.com/users/6616", "pm_score": 2, "selected": true, "text": "<p>You can override the Post type object settings in the <code>init</code> action and register the proper values for th...
2012/02/23
[ "https://wordpress.stackexchange.com/questions/43231", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6616/" ]
I have set the following custom permalink structure (for my blog): ``` /news/%postname% ``` When I browse to `/news` I was expecting for the `archive.php` template to be served up, unfortunately, I'm presented with a 404. My rewrite is working properly since I can view all posts such as `/news/my-post-title`. How ...
You can override the Post type object settings in the `init` action and register the proper values for the archive and rewrites: ``` add_action('init', 'my_init'); function my_init() { $args = objectToArray( get_post_type_object('post') ); $args['has_archive'] = 'news'; $args['rewrite'] = array( 'slug...
43,238
<p>My current singlepost.php makes use of the following if conditions and renders the appropriate template.</p> <pre><code>&lt;?php $post = $wp_query-&gt;post; if ( in_category('4') || in_category('59') ) { include(TEMPLATEPATH . '/review-post.php'); } elseif (in_category('5')) { includ...
[ { "answer_id": 43264, "author": "Tom", "author_id": 1014, "author_profile": "https://wordpress.stackexchange.com/users/1014", "pm_score": 3, "selected": true, "text": "<p>I'm making a couple of assumptions about how your theme is setup:</p>\n\n<ul>\n<li>You have two files:\n<ul>\n<li>ind...
2012/02/23
[ "https://wordpress.stackexchange.com/questions/43238", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5411/" ]
My current singlepost.php makes use of the following if conditions and renders the appropriate template. ``` <?php $post = $wp_query->post; if ( in_category('4') || in_category('59') ) { include(TEMPLATEPATH . '/review-post.php'); } elseif (in_category('5')) { include(TEMPLATEPATH . '/p...
I'm making a couple of assumptions about how your theme is setup: * You have two files: + index.php. This is the file that begins the execution of [the loop](http://codex.wordpress.org/The_Loop). + content.php. This is the file in which your generic content template exists. * You are familiar with [get\_template\_pa...
43,262
<h1>The task</h1> <p>You can register add additional Themes directories using <code>register_theme_directory()</code> for your WP installation. Sadly core doesn't deliver with the same functionality for plugins. We already have MU-Plugin, Drop-Ins, Plugins and Themes. But we need more for a better file organization.</...
[ { "answer_id": 44995, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 6, "selected": true, "text": "<p>Okay, I'll take a stab at this. Some limitations I encountered along the way:</p>\n\n<ol>\n<li><p>There ar...
2012/02/23
[ "https://wordpress.stackexchange.com/questions/43262", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/385/" ]
The task ======== You can register add additional Themes directories using `register_theme_directory()` for your WP installation. Sadly core doesn't deliver with the same functionality for plugins. We already have MU-Plugin, Drop-Ins, Plugins and Themes. But we need more for a better file organization. ### Here's the...
Okay, I'll take a stab at this. Some limitations I encountered along the way: 1. There are not a lot of filters in subclasses of WP\_List\_Table, at least no where we need them to be. 2. Due to that lack of filters, we can't really maintain an accurate list of plugin types at the top. 3. We also have to use some aweso...
43,267
<p>Slight problem, I have the following code:</p> <pre><code>$purchaseprodid = $_GET['ids']; $args = array( 'post_type' =&gt; 'prizes', 'post__in' =&gt; array($purchaseprodid) ); query_posts($args); while (have_posts()) : the_post()...
[ { "answer_id": 43269, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 3, "selected": true, "text": "<p>You need to explode the string you obtain from <code>$_GET['ids']</code> into an array, at the moment you ...
2012/02/23
[ "https://wordpress.stackexchange.com/questions/43267", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10645/" ]
Slight problem, I have the following code: ``` $purchaseprodid = $_GET['ids']; $args = array( 'post_type' => 'prizes', 'post__in' => array($purchaseprodid) ); query_posts($args); while (have_posts()) : the_post(); ``` I am gettin...
You need to explode the string you obtain from `$_GET['ids']` into an array, at the moment you a parsing a to string `post__in` rather than an array of IDs. Try ``` $purchaseprodid = isset($_GET['ids']) ? explode(',',$_GET['ids']) : array(); ``` However, you can sometimes run into difficulties using `$_GET` with Wo...
43,277
<p>I have a custom metabox, where I store the date in plain text like this: <code>dd/mm/yy</code>and now I need to order the posts by that date.The custom field is called <code>event_informations_date</code></p> <pre><code>&lt;?php $args = array( 'post_type' =&gt; 'Event','posts_per_page' =&gt; 1000 ); $loop =...
[ { "answer_id": 43280, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 0, "selected": false, "text": "<p>first you'll need to add more parameters </p>\n\n<pre><code>$args = array( 'post_type' =&gt; 'Event',\n ...
2012/02/23
[ "https://wordpress.stackexchange.com/questions/43277", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12011/" ]
I have a custom metabox, where I store the date in plain text like this: `dd/mm/yy`and now I need to order the posts by that date.The custom field is called `event_informations_date` ``` <?php $args = array( 'post_type' => 'Event','posts_per_page' => 1000 ); $loop = new WP_Query( $args ); ?> <?php while ( $loo...
When you're saving the data on your custom post type you need to set it so that the meta box value is actually stored as a UNIX timestamp, eg: ``` if(!isset($_POST["event_informations_date"])) { return $post; } else { $event_as_timestamp = strtotime ( $_POST["event_informations_date"]; update_post_meta($po...
43,281
<p>I'm trying to add the value of a custom field under the post/page title in wp-admin list of posts/pages (much like excerpt mode in posts list) without hooking into the columns process since other plugins are already doing that and it looks like each cancels the other.</p> <p>Here's a screenshot of what I'm trying t...
[ { "answer_id": 43300, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 1, "selected": false, "text": "<p>You can hook into the post_row_actions as follows:</p>\n\n<pre><code>add_filter('post_row_actions', 'wpse_4...
2012/02/23
[ "https://wordpress.stackexchange.com/questions/43281", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20/" ]
I'm trying to add the value of a custom field under the post/page title in wp-admin list of posts/pages (much like excerpt mode in posts list) without hooking into the columns process since other plugins are already doing that and it looks like each cancels the other. Here's a screenshot of what I'm trying to achieve:...
Just like you add new columns you render the title filed your self ``` add_action( 'manage_posts_custom_column', 'admin_post_data_row', 10, 2); function admin_post_data_row($column_name, $post_id) { switch($column_name){ case 'title': edit_post_link(get_post_title($post_id), '<p>', '</p>...
43,282
<p>I'm using a us/news/%postname%/ structure for my permalinks. This works great for regular posts.</p> <p>However, I have a few different custom post types, and I don't want the us/news part in their slug.</p> <p>How do I have it both ways?</p>
[ { "answer_id": 43285, "author": "Kyle", "author_id": 12476, "author_profile": "https://wordpress.stackexchange.com/users/12476", "pm_score": 1, "selected": false, "text": "<p>You could change your permalink structure to <code>/%category%/%postname%/</code> and add the posts to a News cat...
2012/02/23
[ "https://wordpress.stackexchange.com/questions/43282", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12593/" ]
I'm using a us/news/%postname%/ structure for my permalinks. This works great for regular posts. However, I have a few different custom post types, and I don't want the us/news part in their slug. How do I have it both ways?
You can do this by setting `'with_front' => false` while registering the new custom post type, To remove the custom post type slug which Wordpress adds by default, pass `'slug'=>''` empty. E.g. ``` //Example - how to pass array to rewrite $args = array( // This rewrite settings will remove the slug you want also ...
43,298
<p>I am displaying only thumbs and title on index pages using following code;</p> <pre><code> &lt;div id="column1"&gt; &lt;?php query_posts('cat=22&amp;showposts=2'); ?&gt; &lt;?php $posts = get_posts('cat=22&amp;numberposts=2&amp;offset=0'); foreach ($posts as $post) : start_wp(); ?&gt; &lt;?php static $count1 = ...
[ { "answer_id": 43319, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 0, "selected": false, "text": "<p>if i understand you correctly, the following will get the posts and put them into rows, at 3 posts per ro...
2012/02/23
[ "https://wordpress.stackexchange.com/questions/43298", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9711/" ]
I am displaying only thumbs and title on index pages using following code; ``` <div id="column1"> <?php query_posts('cat=22&showposts=2'); ?> <?php $posts = get_posts('cat=22&numberposts=2&offset=0'); foreach ($posts as $post) : start_wp(); ?> <?php static $count1 = 0; if ($count1 == "2") { break; } else { ?> <a ...
Easiest way to control column and/or row layouts I know of is to make use of modulus. I broke it down in a tutorial and use it with wordpress in my examples. [Wordpress and PHP Modulus](http://unrelatedmedia.ca/tutorial/php-grid-with-modulus-and-wordpress) The first example is basic, while the second is a bit more a...
43,310
<p>I have three different posts types registered:</p> <pre><code>register_post_type( 'foo' , $args ); register_post_type( 'bar' , $args ); register_post_type( 'baz' , $args ); </code></pre> <p>When I am creating a new, say, "foo" post, I only want to save the meta box for "foo", what do I do?</p> <p>add_action('save...
[ { "answer_id": 43312, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 0, "selected": false, "text": "<p>I assume you're talking about a <em>custom</em> post meta box? If so, then you need to ensure that you *spe...
2012/02/23
[ "https://wordpress.stackexchange.com/questions/43310", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2417/" ]
I have three different posts types registered: ``` register_post_type( 'foo' , $args ); register_post_type( 'bar' , $args ); register_post_type( 'baz' , $args ); ``` When I am creating a new, say, "foo" post, I only want to save the meta box for "foo", what do I do? add\_action('save\_post', 'save\_details'); So, ...
Since save\_post gives you the post\_id of the current post, you simply want to check what post\_type it is by using get\_post\_type($post\_id) like: ``` add_action('save_post', 'save_details') function save_details($post_id) { $post_type = $_REQUEST['post_type']; if ('foo_post' == $post_type) { ...
43,320
<p>I'd like to run an SQL query to find all featured images from posts and delete the file itself and any references to it.</p> <p>Can anyone tell me how to accomplish this? Many thanks!</p>
[ { "answer_id": 43323, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 3, "selected": true, "text": "<p>A MYSQL Query cannot delete the files themselves. You will have to use wp_delete_attachment(). The following...
2012/02/23
[ "https://wordpress.stackexchange.com/questions/43320", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13142/" ]
I'd like to run an SQL query to find all featured images from posts and delete the file itself and any references to it. Can anyone tell me how to accomplish this? Many thanks!
A MYSQL Query cannot delete the files themselves. You will have to use wp\_delete\_attachment(). The following is a proof-of-concept for you to alter how you please. The featured image is stored in postmeta as `_thumbnail_id`. `wp_delete_attachment()` does the rest for you. ``` <?php /* Plugin Name: Delete All Feature...
43,329
<p>I'm working on a site and I need to get the type of user the author is so I can mark it.</p> <p>The idea is that if an Admin level user post something it has a [ADMIN] tag or something next to their name. I know how to compare things within php but how do I check to see what user type an author is if possible? I ca...
[ { "answer_id": 43333, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 0, "selected": false, "text": "<p>in the loop: </p>\n\n<pre><code>the_author_meta('user_level'); \n</code></pre>\n\n<p>will get you the cap...
2012/02/23
[ "https://wordpress.stackexchange.com/questions/43329", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7006/" ]
I'm working on a site and I need to get the type of user the author is so I can mark it. The idea is that if an Admin level user post something it has a [ADMIN] tag or something next to their name. I know how to compare things within php but how do I check to see what user type an author is if possible? I can't seem t...
One way would be to use the `get_the_author_meta` function and pass it `user_level` More info on the function: <http://codex.wordpress.org/Function_Reference/get_the_author_meta> Then, see this chart to convert user levels to roles (unless you have created custom roles): <http://codex.wordpress.org/Roles_and_Capabili...
43,336
<p>I'm trying to display related posts by a custom taxonomy (product_tags) in a custom post type (products). The following code works, but it ignores <strong>posts_per_page</strong>.</p> <p>Any ideas?</p> <pre><code> global $post; $terms = get_the_terms( $post-&gt;ID , 'product_tags', '...
[ { "answer_id": 43338, "author": "Zach Lysobey", "author_id": 5846, "author_profile": "https://wordpress.stackexchange.com/users/5846", "pm_score": 0, "selected": false, "text": "<p>This probably isn't the correct solution, but I would start by moving <code>$term-&gt;slug</code>:</p>\n\n<...
2012/02/23
[ "https://wordpress.stackexchange.com/questions/43336", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13467/" ]
I'm trying to display related posts by a custom taxonomy (product\_tags) in a custom post type (products). The following code works, but it ignores **posts\_per\_page**. Any ideas? ``` global $post; $terms = get_the_terms( $post->ID , 'product_tags', 'string'); $do_not_...
If you want to query for multiple taxonomy terms you can use the more advanced, [`tax_query`](http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters) argument of WP\_Query queries. For instance ``` //Get array of terms $terms = get_the_terms( $post->ID , 'product_tags', 'string'); //Pluck out the IDs ...
43,372
<p>I have an url that looks like this <a href="http://apploadny.appload.nu/tjanster/webbutveckling/" rel="nofollow">http://apploadny.appload.nu/tjanster/webbutveckling/</a> I want to get the ID of the page "tjanster", how can i do that?</p>
[ { "answer_id": 43374, "author": "alexleonard", "author_id": 11169, "author_profile": "https://wordpress.stackexchange.com/users/11169", "pm_score": 4, "selected": true, "text": "<p>I think what you need is:</p>\n\n<pre><code>&lt;?php \n$post_id = $post-&gt;ID; //or somehow get the curren...
2012/02/24
[ "https://wordpress.stackexchange.com/questions/43372", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13121/" ]
I have an url that looks like this <http://apploadny.appload.nu/tjanster/webbutveckling/> I want to get the ID of the page "tjanster", how can i do that?
I think what you need is: ``` <?php $post_id = $post->ID; //or somehow get the current post ID. $ancestors = get_post_ancestors($post_id) //$ancestors is an array of post IDs starting with the current post going up the root //'Pop' the root ancestor out or returns the current ID if the post has no ancestors. $root_...
43,386
<p>I have a simple form that users will fill out which will in turn become a post on my site. I have 2 problems:</p> <ol> <li><p>I am using the Post title, Post Custom Field elements (for single line text) and Post Body element (for paragraph text). When I submit my test form though, only the title is appearing, none ...
[ { "answer_id": 43374, "author": "alexleonard", "author_id": 11169, "author_profile": "https://wordpress.stackexchange.com/users/11169", "pm_score": 4, "selected": true, "text": "<p>I think what you need is:</p>\n\n<pre><code>&lt;?php \n$post_id = $post-&gt;ID; //or somehow get the curren...
2012/02/24
[ "https://wordpress.stackexchange.com/questions/43386", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13490/" ]
I have a simple form that users will fill out which will in turn become a post on my site. I have 2 problems: 1. I am using the Post title, Post Custom Field elements (for single line text) and Post Body element (for paragraph text). When I submit my test form though, only the title is appearing, none of the data I wr...
I think what you need is: ``` <?php $post_id = $post->ID; //or somehow get the current post ID. $ancestors = get_post_ancestors($post_id) //$ancestors is an array of post IDs starting with the current post going up the root //'Pop' the root ancestor out or returns the current ID if the post has no ancestors. $root_...
43,392
<p>I creating a custom footer navigation in wordpress. I looked all over the wordpress documentation and still haven't found anything. So, what I'm trying to do is add an "|" in the navigation like this:</p> <blockquote> <p>Home | Link 1 | Link 2 | Link 3 | Contact</p> </blockquote> <p>I know there's a way in CSS, ...
[ { "answer_id": 43393, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 1, "selected": false, "text": "<p><code>wp_nav_menu</code> has a <code>$before</code>and <code>$after</code> parameters which you can use to ad...
2012/02/24
[ "https://wordpress.stackexchange.com/questions/43392", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9707/" ]
I creating a custom footer navigation in wordpress. I looked all over the wordpress documentation and still haven't found anything. So, what I'm trying to do is add an "|" in the navigation like this: > > Home | Link 1 | Link 2 | Link 3 | Contact > > > I know there's a way in CSS, but I know this is generated by ...
I figured out a way to do this and without using the wp\_nav\_menu. Here's the code to do this and hope it might help other (Note: You need to create a menu in the admin panel to have this work). ``` <p> <?php $items = wp_get_nav_menu_items("footer"); ...
43,395
<p>I have two cpt's, events and reports, they both share the taxonomy locations, I have my taxonomy-locations.php, but that is showing reports &amp; events for location, I just want to show reports for location. Can someone help me out with how this query should go?</p> <p>Thanks</p>
[ { "answer_id": 43396, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 2, "selected": true, "text": "<p>Before the loop in your <code>taxonomy-locations.php</code> file, </p>\n\n<pre><code>global $wp_query;\n$a...
2012/02/24
[ "https://wordpress.stackexchange.com/questions/43395", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4090/" ]
I have two cpt's, events and reports, they both share the taxonomy locations, I have my taxonomy-locations.php, but that is showing reports & events for location, I just want to show reports for location. Can someone help me out with how this query should go? Thanks
Before the loop in your `taxonomy-locations.php` file, ``` global $wp_query; $args = array_merge( $wp_query->query, array( 'post_type' => 'report' ) ); query_posts( $args ); ``` You could, alternatively, modify the query using an appropriate hook (this would be the most effecient method) - but since it is run for m...
43,397
<p>Trying to get posts from a <strong>specific category</strong> for <strong>specific years</strong>. Nothing is working, including this:</p> <pre><code>&lt;?php $args=array( 'cat' =&gt; '11', //Category I'm targeting 'year' =&gt; 2008,2009,2010 //Years I want ); $my_query = new WP_Query($args); if( $my_query-&gt;have...
[ { "answer_id": 43396, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 2, "selected": true, "text": "<p>Before the loop in your <code>taxonomy-locations.php</code> file, </p>\n\n<pre><code>global $wp_query;\n$a...
2012/02/24
[ "https://wordpress.stackexchange.com/questions/43397", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13496/" ]
Trying to get posts from a **specific category** for **specific years**. Nothing is working, including this: ``` <?php $args=array( 'cat' => '11', //Category I'm targeting 'year' => 2008,2009,2010 //Years I want ); $my_query = new WP_Query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_q...
Before the loop in your `taxonomy-locations.php` file, ``` global $wp_query; $args = array_merge( $wp_query->query, array( 'post_type' => 'report' ) ); query_posts( $args ); ``` You could, alternatively, modify the query using an appropriate hook (this would be the most effecient method) - but since it is run for m...
43,409
<p>I added two category pages to a site I am working on and I found out the permalink in the url is wrong.</p> <p>I set the permalink as <code>/%category%/%postname%</code> and I created two categories "News" and "Offers"</p> <p>I was supposed to get <code>mydomain.com/news</code> or <code>mydomain.com/offers</code> ...
[ { "answer_id": 43396, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 2, "selected": true, "text": "<p>Before the loop in your <code>taxonomy-locations.php</code> file, </p>\n\n<pre><code>global $wp_query;\n$a...
2012/02/24
[ "https://wordpress.stackexchange.com/questions/43409", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2618/" ]
I added two category pages to a site I am working on and I found out the permalink in the url is wrong. I set the permalink as `/%category%/%postname%` and I created two categories "News" and "Offers" I was supposed to get `mydomain.com/news` or `mydomain.com/offers` (I created the category links using the built-in m...
Before the loop in your `taxonomy-locations.php` file, ``` global $wp_query; $args = array_merge( $wp_query->query, array( 'post_type' => 'report' ) ); query_posts( $args ); ``` You could, alternatively, modify the query using an appropriate hook (this would be the most effecient method) - but since it is run for m...
43,419
<p>Basic idea is for any post on the site, I'd like users to be able to assign a category for it by selecting from a set of checkboxes on the frontend. This would be a kind of crowd-sourced categorization of content.</p> <p>Any ideas on the best way to approach this?</p>
[ { "answer_id": 43432, "author": "Neil Davidson", "author_id": 12426, "author_profile": "https://wordpress.stackexchange.com/users/12426", "pm_score": -1, "selected": false, "text": "<p>The approach I would use would be update post and using in_array to see if the category has already bee...
2012/02/24
[ "https://wordpress.stackexchange.com/questions/43419", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13502/" ]
Basic idea is for any post on the site, I'd like users to be able to assign a category for it by selecting from a set of checkboxes on the frontend. This would be a kind of crowd-sourced categorization of content. Any ideas on the best way to approach this?
I wanted to provide you with a few ideas but once I started I couldn't stop myself and wrote this little plugin with an obscure name to get you started. ``` <?php /* Plugin Name: WPSE Crowded Cats Plugin URI: http://wordpress.stackexchange.com/questions/43419/how-do-i-create-a-way-for-users-to-assign-categories-to-a-...
43,421
<p>Help!</p> <p>I am trying to create a Digg-clone by integrating "BM Shots" (a webpage thumbnail generator) with "Recommended Links" (a social voting plug-in for Wordpress). Recommended Links allows for user submitted URLs to be displayed via "the_permalink" tag. I'm trying to use BM Shots to generate web page thumbn...
[ { "answer_id": 43422, "author": "Rob Vermeer", "author_id": 11135, "author_profile": "https://wordpress.stackexchange.com/users/11135", "pm_score": 0, "selected": false, "text": "<p><code>the_permalink()</code> echoes the permalink, <code>get_permalink()</code> returns the permalink. So ...
2012/02/24
[ "https://wordpress.stackexchange.com/questions/43421", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13504/" ]
Help! I am trying to create a Digg-clone by integrating "BM Shots" (a webpage thumbnail generator) with "Recommended Links" (a social voting plug-in for Wordpress). Recommended Links allows for user submitted URLs to be displayed via "the\_permalink" tag. I'm trying to use BM Shots to generate web page thumbnails base...
`the_permalink()` is actually filtered in the Recommended Links plugin to echo a custom meta field called `_href`. If you want access to that field without echoing it, you can use `get_post_meta( $post->ID, '_href', true )`. Try something like this in your loop: ``` global $post; // may or may not be necessary $url ...
43,425
<p>I have a top level page with a lot of subpages. <br /> When a user visits the top level page they currently see the titles/thumbnails/excerpts of <strong>all</strong> of the subpages. <br /> How can I paginate the display of the subpages so that <strong>only</strong> 3 are displayed at a time, giving the user the ab...
[ { "answer_id": 43422, "author": "Rob Vermeer", "author_id": 11135, "author_profile": "https://wordpress.stackexchange.com/users/11135", "pm_score": 0, "selected": false, "text": "<p><code>the_permalink()</code> echoes the permalink, <code>get_permalink()</code> returns the permalink. So ...
2012/02/24
[ "https://wordpress.stackexchange.com/questions/43425", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10878/" ]
I have a top level page with a lot of subpages. When a user visits the top level page they currently see the titles/thumbnails/excerpts of **all** of the subpages. How can I paginate the display of the subpages so that **only** 3 are displayed at a time, giving the user the ability to navigate via the typcial "< Prev...
`the_permalink()` is actually filtered in the Recommended Links plugin to echo a custom meta field called `_href`. If you want access to that field without echoing it, you can use `get_post_meta( $post->ID, '_href', true )`. Try something like this in your loop: ``` global $post; // may or may not be necessary $url ...
43,426
<p>I am looking for a solution that allows me to print the following:</p> <pre><code>Cat 1 Cat 2 Cat 3 Post 1 Post 1 Post 1 Post 2 Post 2 Post 2 Post 3 Post 3 Post 4 </code></pre> <p><strong>EDIT</strong></p> <p>I am looking for s...
[ { "answer_id": 43428, "author": "jasonflaherty", "author_id": 13343, "author_profile": "https://wordpress.stackexchange.com/users/13343", "pm_score": -1, "selected": false, "text": "<p>if you are looking for a plugin, <a href=\"http://wordpress.org/extend/plugins/list-category-posts/othe...
2012/02/24
[ "https://wordpress.stackexchange.com/questions/43426", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6194/" ]
I am looking for a solution that allows me to print the following: ``` Cat 1 Cat 2 Cat 3 Post 1 Post 1 Post 1 Post 2 Post 2 Post 2 Post 3 Post 3 Post 4 ``` **EDIT** I am looking for something that will only require *one* database...
**EDIT REVISIT NO 2** I have never touched the [Transient API](http://codex.wordpress.org/Transients_API), until today when I saw @MikeSchinkel answer in [this post](https://wordpress.stackexchange.com/a/912/31545). This inspired me to revisit this post once again. After some testing, I came up with the following: * ...
43,444
<p>I am using wp_nav_menu() and I want to add the search box as a part of the menu.</p> <p>I am having trouble figuring it out and was hoping for some assistance:</p> <p>My code:</p> <pre><code> &lt;?php $args = array('theme_location' =&gt; 'primary', 'container' =&gt; false); wp_nav_menu( $a...
[ { "answer_id": 43428, "author": "jasonflaherty", "author_id": 13343, "author_profile": "https://wordpress.stackexchange.com/users/13343", "pm_score": -1, "selected": false, "text": "<p>if you are looking for a plugin, <a href=\"http://wordpress.org/extend/plugins/list-category-posts/othe...
2012/02/24
[ "https://wordpress.stackexchange.com/questions/43444", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10368/" ]
I am using wp\_nav\_menu() and I want to add the search box as a part of the menu. I am having trouble figuring it out and was hoping for some assistance: My code: ``` <?php $args = array('theme_location' => 'primary', 'container' => false); wp_nav_menu( $args ); ?> ``` Now I want...
**EDIT REVISIT NO 2** I have never touched the [Transient API](http://codex.wordpress.org/Transients_API), until today when I saw @MikeSchinkel answer in [this post](https://wordpress.stackexchange.com/a/912/31545). This inspired me to revisit this post once again. After some testing, I came up with the following: * ...
43,446
<p>Is it possible to create a Wordpress install that will automatically install with multiple plugins, a particular theme and custom settings so when I setup multiple blogs I don't have install so much extras each time?</p> <p>It's because I will be installing lots of Wordpress blogs of different kinds that require di...
[ { "answer_id": 43454, "author": "Michal Mau", "author_id": 2110, "author_profile": "https://wordpress.stackexchange.com/users/2110", "pm_score": 1, "selected": false, "text": "<p>In the past I've had success in making custom WP installations using custom <code>install.php</code> file. I ...
2012/02/25
[ "https://wordpress.stackexchange.com/questions/43446", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13366/" ]
Is it possible to create a Wordpress install that will automatically install with multiple plugins, a particular theme and custom settings so when I setup multiple blogs I don't have install so much extras each time? It's because I will be installing lots of Wordpress blogs of different kinds that require different pl...
If you have access to your host commandline and are running linux, why not pair [wp\_cli](http://wp-cli.org/) with a bash script. In this way you can have a fairly defined standard set of plugins to activate per install. ``` wp plugin activate plugin_a wp plugin activate plugin_b wp plugin activate plugin_c ``` Her...
43,463
<p>What is the recommended way to approach the follow issue? I have to create two pages. On one page I will have a small form where users will be able to register themselves (with or without photo). On the other page, I will show all the users' info entered on the previous form. For the admin section, I just need to ha...
[ { "answer_id": 43466, "author": "andresmijares", "author_id": 4907, "author_profile": "https://wordpress.stackexchange.com/users/4907", "pm_score": 0, "selected": false, "text": "<p>I would face it this way:</p>\n\n<ul>\n<li>Installing <a href=\"http://wordpress.org/extend/plugins/contac...
2012/02/25
[ "https://wordpress.stackexchange.com/questions/43463", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9060/" ]
What is the recommended way to approach the follow issue? I have to create two pages. On one page I will have a small form where users will be able to register themselves (with or without photo). On the other page, I will show all the users' info entered on the previous form. For the admin section, I just need to have ...
The following code creates a new role. In fact is simply clones the subscriber role, so if you are not using that role currently, you may as well just use that. *The following function need only be run once (it run's when a user is 'admin side')* ``` //Creates a custom role called 'my_new_role'. //Run this once then ...
43,477
<p>I have a website which has a static front page and a blog page where all the blogs are displayed.</p> <p>I am using my own theme and have created some custom meta boxes that display content in a sidebar based on the return value from <code>$post-&gt;ID</code>. The interesting behaviour I am getting is that <code>$p...
[ { "answer_id": 43478, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 1, "selected": false, "text": "<p>If you are using <code>query_posts</code> (which has some drawbacks since it alters the main loop), as th...
2012/02/25
[ "https://wordpress.stackexchange.com/questions/43477", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11465/" ]
I have a website which has a static front page and a blog page where all the blogs are displayed. I am using my own theme and have created some custom meta boxes that display content in a sidebar based on the return value from `$post->ID`. The interesting behaviour I am getting is that `$post->ID` gives me the ID of t...
consider to use: ``` $postspage_id = get_option('page_for_posts'); ``` and then change the rspective line in your code to: ``` $leftSidebar = get_post_meta( $postspage_id, '_my_meta', true ); ``` from: <http://www.blog.highub.com/cms/wordpress/wordpress-front-page-posts-page-id/>
43,485
<p>My homepage has 1 featured post, followed by 4 posts stacked 2 on 2, like this:</p> <p><img src="https://i.stack.imgur.com/3XOkv.png" alt="enter image description here"></p> <p>The featured post is only shown on the first page so the second page shows the older posts stacked 2 by 2 as above.</p> <p>However, I'd l...
[ { "answer_id": 43487, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 3, "selected": true, "text": "<p>To load override WordPress' choice of template you can use <code>template_include</code> <strong>filter</s...
2012/02/25
[ "https://wordpress.stackexchange.com/questions/43485", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5352/" ]
My homepage has 1 featured post, followed by 4 posts stacked 2 on 2, like this: ![enter image description here](https://i.stack.imgur.com/3XOkv.png) The featured post is only shown on the first page so the second page shows the older posts stacked 2 by 2 as above. However, I'd like to be able to change the layout on...
To load override WordPress' choice of template you can use `template_include` **filter** and then use the [`locate_template`](http://codex.wordpress.org/Function_Reference/locate_template) to return the the template file path (if it finds it). The file-name passed to `locate_template` must be the name of the template ...
43,489
<p>I created a page for my custom post types. The code can be viewed on Snippi: <a href="http://snippi.com/s/e8852rx" rel="nofollow">http://snippi.com/s/e8852rx</a></p> <p>I'm trying to insert paginate_links, but for whatever reason it's simply not showing up. Here is the paginate_links code (this code works on norm...
[ { "answer_id": 43901, "author": "David Gard", "author_id": 10097, "author_profile": "https://wordpress.stackexchange.com/users/10097", "pm_score": 0, "selected": false, "text": "<p>You are refernecing the main query, so it's likely that it's trying to show 'posts' only, as opposed to you...
2012/02/25
[ "https://wordpress.stackexchange.com/questions/43489", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5205/" ]
I created a page for my custom post types. The code can be viewed on Snippi: <http://snippi.com/s/e8852rx> I'm trying to insert paginate\_links, but for whatever reason it's simply not showing up. Here is the paginate\_links code (this code works on normal archive.php files): ``` <?php global $wp_query; $big = 99999...
The following works for me (I've removed all the formating / custom post meta). I would add, its not clear why you need to use a page with a custom template, and don't instead create a template called `archive-portfolio.php` which is used for a custom post type's archive pages (see [template hierarchy](http://codex.wo...
43,500
<p>Is there a way to make a dashboard contact form widget?</p> <p>I just simply want to have it there so users can give feedback directly from their dashboard.</p>
[ { "answer_id": 43501, "author": "chriswallace", "author_id": 13530, "author_profile": "https://wordpress.stackexchange.com/users/13530", "pm_score": 2, "selected": true, "text": "<p>Yes. You can do this by <a href=\"http://codex.wordpress.org/Function_Reference/wp_add_dashboard_widget\" ...
2012/02/25
[ "https://wordpress.stackexchange.com/questions/43500", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5698/" ]
Is there a way to make a dashboard contact form widget? I just simply want to have it there so users can give feedback directly from their dashboard.
Yes. You can do this by [adding a dashboard widget](http://codex.wordpress.org/Function_Reference/wp_add_dashboard_widget) with a contact form function that uses AJAX to submit the form. ``` function myplugin_dashboard_widget() { ajax_contact_form(); } function myplugin_add_dashboard_widgets() { wp_add_dashbo...
43,517
<p>I look up a custom post field value in header.php, and store it in a global variable. </p> <p>In most of my template files, the includes go like this:</p> <pre><code>include header ...do a bunch of stuff include sidebar include footer </code></pre> <p>I can not persist the variable into the footer.php file... <...
[ { "answer_id": 43521, "author": "Sagive", "author_id": 7990, "author_profile": "https://wordpress.stackexchange.com/users/7990", "pm_score": 0, "selected": false, "text": "<p>You can...</p>\n\n<p>Create a function in <strong>functions.php</strong> file that asks for the custom field and ...
2012/02/25
[ "https://wordpress.stackexchange.com/questions/43517", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13228/" ]
I look up a custom post field value in header.php, and store it in a global variable. In most of my template files, the includes go like this: ``` include header ...do a bunch of stuff include sidebar include footer ``` I can not persist the variable into the footer.php file... is there any way to do this so t...
You'd have to declare it first above those includes and globalize it within header or footer before getting or setting the value. however- in the specific context you're speaking of- getting a custom field value, it's only retrieved from the database on the first call, then cached, so subsequent calls won't hit the da...
43,528
<p>I want to replace get_author_link() and get_the_author_meta($feld)</p> <p>with something equivalent to point to the author of the current post Buddypress user profile page and retrieve a specific profile field from his Buddypress page</p> <p>ie, I just want to show a link to the post user profile and a biography f...
[ { "answer_id": 45345, "author": "Boone Gorges", "author_id": 14052, "author_profile": "https://wordpress.stackexchange.com/users/14052", "pm_score": 6, "selected": true, "text": "<p>For an author's profile link, use</p>\n\n<pre><code>bp_core_get_user_domain( $user_id )\n</code></pre>\n\n...
2012/02/26
[ "https://wordpress.stackexchange.com/questions/43528", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8421/" ]
I want to replace get\_author\_link() and get\_the\_author\_meta($feld) with something equivalent to point to the author of the current post Buddypress user profile page and retrieve a specific profile field from his Buddypress page ie, I just want to show a link to the post user profile and a biography from one of h...
For an author's profile link, use ``` bp_core_get_user_domain( $user_id ) ``` to get the URL, and ``` bp_core_get_userlink( $user_id ) ``` to get an HTML link element, including display name. For the xprofile data, use ``` xprofile_get_field_data( $field, $user_id ) ``` `$field` can be either the name of the ...
43,529
<p><strong>Background Info</strong></p> <p>I sell WordPress themes where I include a Twitter widget. In the widget I use a WordPress transient that refreshes every 3 hours to cache the Tweets. I've got thousands of people using this and it seems to work for just about everyone. Also, I've done little tests on my end t...
[ { "answer_id": 45345, "author": "Boone Gorges", "author_id": 14052, "author_profile": "https://wordpress.stackexchange.com/users/14052", "pm_score": 6, "selected": true, "text": "<p>For an author's profile link, use</p>\n\n<pre><code>bp_core_get_user_domain( $user_id )\n</code></pre>\n\n...
2012/02/26
[ "https://wordpress.stackexchange.com/questions/43529", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8193/" ]
**Background Info** I sell WordPress themes where I include a Twitter widget. In the widget I use a WordPress transient that refreshes every 3 hours to cache the Tweets. I've got thousands of people using this and it seems to work for just about everyone. Also, I've done little tests on my end to ensure I know the cac...
For an author's profile link, use ``` bp_core_get_user_domain( $user_id ) ``` to get the URL, and ``` bp_core_get_userlink( $user_id ) ``` to get an HTML link element, including display name. For the xprofile data, use ``` xprofile_get_field_data( $field, $user_id ) ``` `$field` can be either the name of the ...
43,543
<p>I am trying to use a menu which I have partially working, I have setup functions.php:</p> <pre><code>if (function_exists('register_nav_menu')) { register_nav_menu('main-menu', 'Main Menu'); } </code></pre> <p>I have configured the menu in Appearance -> Menus with 2 Pages: Home &amp; Sample Page.</p> <p>My Probl...
[ { "answer_id": 43544, "author": "Jeremy Jared", "author_id": 5339, "author_profile": "https://wordpress.stackexchange.com/users/5339", "pm_score": 0, "selected": false, "text": "<p>Make sure you're adding the <code>register_nav_menu</code> function inside of <code>after_theme_setup</code...
2012/02/26
[ "https://wordpress.stackexchange.com/questions/43543", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10368/" ]
I am trying to use a menu which I have partially working, I have setup functions.php: ``` if (function_exists('register_nav_menu')) { register_nav_menu('main-menu', 'Main Menu'); } ``` I have configured the menu in Appearance -> Menus with 2 Pages: Home & Sample Page. My Problem: When I call the menu using wp\_n...
I'm not sure if I've followed you correctly; but I think you're trying to build the Menu HTML entirely on your own. If I'm correct, then what you're trying to do is covered under **"Walker"** object of wp-nav-menu. You need to write a separate function in your functions.php and then pass the function name as "walker"...
43,545
<p>I have a music player in my theme that generates its playlist from a javascript file that looks like this</p> <pre><code>var myPlaylist = [ { mp3:'track url goes here', title:'title here', artist:'artist', } { mp3:'track url goes here', title:'title here', ...
[ { "answer_id": 43547, "author": "ungestaltbar", "author_id": 12449, "author_profile": "https://wordpress.stackexchange.com/users/12449", "pm_score": 3, "selected": true, "text": "<p>Welcome to WPSE marctain!</p>\n\n<p><strong>Edit</strong>\nThere are some critiques on using the guid but ...
2012/02/26
[ "https://wordpress.stackexchange.com/questions/43545", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13545/" ]
I have a music player in my theme that generates its playlist from a javascript file that looks like this ``` var myPlaylist = [ { mp3:'track url goes here', title:'title here', artist:'artist', } { mp3:'track url goes here', title:'title here', artist:'arti...
Welcome to WPSE marctain! **Edit** There are some critiques on using the guid but no one of the commentators managed to edit this answer to a better one, so I'll do it. Yes, using guid is a bad idea in the long run, I knew that and I should have pointed that out, I didn't, it was a mistake. I'm sorry, it was a quick ...
43,549
<p>What I am trying to do is modification of this function on codex <a href="http://codex.wordpress.org/Function_Reference/count_user_posts" rel="nofollow">http://codex.wordpress.org/Function_Reference/count_user_posts</a> Check the title <strong>adding post type support</strong> bottom of the page. The function is:</p...
[ { "answer_id": 43552, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 4, "selected": true, "text": "<p>Here is a quick solution to get the post count any kind of filtering you want</p>\n<pre><code>function custom_...
2012/02/26
[ "https://wordpress.stackexchange.com/questions/43549", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13546/" ]
What I am trying to do is modification of this function on codex <http://codex.wordpress.org/Function_Reference/count_user_posts> Check the title **adding post type support** bottom of the page. The function is: ``` function count_user_posts_by_type($userid, $post_type='post') { global $wpdb; $where = get_posts_by...
Here is a quick solution to get the post count any kind of filtering you want ``` function custom_get_user_posts_count($user_id, $args ){ $args['author'] = $user_id; $args['fields'] = 'ids'; $ps = get_posts($args); return count($ps); } ``` Since this function uses [`get_posts`](https://codex.wordpre...
43,558
<p>It's been talked many times that Wordpress outputs some really bad code for the built-in gallery function.</p> <p>This is the core code responsible for the gallery output (in /wp-includes/media.php):</p> <pre><code>function gallery_shortcode($attr) { global $post; static $instance = 0; $instance++; ...
[ { "answer_id": 43562, "author": "Rob Vermeer", "author_id": 11135, "author_profile": "https://wordpress.stackexchange.com/users/11135", "pm_score": 3, "selected": false, "text": "<h2>See <em><a href=\"https://wordpress.stackexchange.com/users/10691/\">badlearner</a>'s</em> edit below</h2...
2012/02/26
[ "https://wordpress.stackexchange.com/questions/43558", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10691/" ]
It's been talked many times that Wordpress outputs some really bad code for the built-in gallery function. This is the core code responsible for the gallery output (in /wp-includes/media.php): ``` function gallery_shortcode($attr) { global $post; static $instance = 0; $instance++; // Allow plugins/t...
Like it was mentioned before removing the shortcode and re-adding it is not the compatible with other plugins modifying galleries so instead you use the `post_gallery` filter hook and the same code from the `gallery_shortcode` function but with your own modification for example, I've commented out the parts you don't w...
43,582
<p>I'm looking for a way to create a parent authors page and then use the <code>author.php</code> for the individual author pages. I've been out of the loop (no pun) for a couple months and am wondering the best way to do it.</p>
[ { "answer_id": 43562, "author": "Rob Vermeer", "author_id": 11135, "author_profile": "https://wordpress.stackexchange.com/users/11135", "pm_score": 3, "selected": false, "text": "<h2>See <em><a href=\"https://wordpress.stackexchange.com/users/10691/\">badlearner</a>'s</em> edit below</h2...
2012/02/26
[ "https://wordpress.stackexchange.com/questions/43582", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13034/" ]
I'm looking for a way to create a parent authors page and then use the `author.php` for the individual author pages. I've been out of the loop (no pun) for a couple months and am wondering the best way to do it.
Like it was mentioned before removing the shortcode and re-adding it is not the compatible with other plugins modifying galleries so instead you use the `post_gallery` filter hook and the same code from the `gallery_shortcode` function but with your own modification for example, I've commented out the parts you don't w...
43,595
<p>i know this is a bit of a weird question but its a real time saver<br /> so if you got any ideas (even partial) i would really apreacate them :)</p> <p>Ok... so i am using wordpress built in interface to capture and disply<br /> remote website images... here is the shortcode i am using..</p> <pre><code>/************...
[ { "answer_id": 43602, "author": "Jonathan Wold", "author_id": 1766, "author_profile": "https://wordpress.stackexchange.com/users/1766", "pm_score": 0, "selected": false, "text": "<p>Accessing the image via Lightbox isn't a problem. While you might run into performance concerns and, of co...
2012/02/27
[ "https://wordpress.stackexchange.com/questions/43595", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7990/" ]
i know this is a bit of a weird question but its a real time saver so if you got any ideas (even partial) i would really apreacate them :) Ok... so i am using wordpress built in interface to capture and disply remote website images... here is the shortcode i am using.. ``` /*************************************...
--- EDITED ANSWER -------------- Forget every thing i said before. Here is what i have found the following 1. In php to generate a website thumbnail, you cant do it natively with php's built in functions, so you have to call an external service or program to do it for you. Since wordpress is basically php , this fa...
43,597
<p>There are heaps of tutorials explaining how to secure a WordPress installation, but I couldn't find any that listed out steps for weekly or monthly security checks. What are some steps that you recommend I perform on a regular basis to keep WordPress secure (besides updating core and plugins)?</p> <p>Here are some ...
[ { "answer_id": 43613, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 3, "selected": false, "text": "<p>First: Remove those 777 permissions. You need this only in cases with conflicting ownership. Try to run PHP as FastCGI...
2012/02/27
[ "https://wordpress.stackexchange.com/questions/43597", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7938/" ]
There are heaps of tutorials explaining how to secure a WordPress installation, but I couldn't find any that listed out steps for weekly or monthly security checks. What are some steps that you recommend I perform on a regular basis to keep WordPress secure (besides updating core and plugins)? Here are some things I'v...
First: Remove those 777 permissions. You need this only in cases with conflicting ownership. Try to run PHP as FastCGI – for example per .htaccess: ``` AddHandler php-cgi .php # or AddHandler php-fastcgi .php ``` Set up a notification mail for every 404 request. You will be surprised how many attacks the average blo...
43,600
<p>Migrating question:</p> <p>How would I structure a MySQL query to move the value from one meta_key to another meta_key? </p> <p>eg: I have an old meta_key of "guest_sort" associated with "posts" to "tf_exhibitor_sort" under the post type "exhibitor_listing"</p> <p>I've already moved the posts from the original po...
[ { "answer_id": 43608, "author": "krembo99", "author_id": 13256, "author_profile": "https://wordpress.stackexchange.com/users/13256", "pm_score": 3, "selected": false, "text": "<p>I hope I understand the question correctly . \nWhen you move a post , the meta keys and values associated wit...
2012/02/27
[ "https://wordpress.stackexchange.com/questions/43600", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8574/" ]
Migrating question: How would I structure a MySQL query to move the value from one meta\_key to another meta\_key? eg: I have an old meta\_key of "guest\_sort" associated with "posts" to "tf\_exhibitor\_sort" under the post type "exhibitor\_listing" I've already moved the posts from the original post category over ...
So, friend came up with a script for this. You put it in your root folder of your instal and it flips the values from one meta key to the other. I thought I'd share it in case anyone else need it. ``` <?php // Functions function db_connect($host,$db,$user,$pass){ if(@mysql_connect($host, $user, $pass)){ @mysq...
43,601
<p>Ok for subdomain it's easy. I guess it just looks up the subdomain:</p> <p><code>blog5.site.com</code></p> <p>=> <code>explode('.', $_SERVER['REQUEST_URI'])...</code></p> <p>But how does it do it for sub-directory setups? This should be interesting considering that pages, taxonomies and what not can take the firs...
[ { "answer_id": 43608, "author": "krembo99", "author_id": 13256, "author_profile": "https://wordpress.stackexchange.com/users/13256", "pm_score": 3, "selected": false, "text": "<p>I hope I understand the question correctly . \nWhen you move a post , the meta keys and values associated wit...
2012/02/27
[ "https://wordpress.stackexchange.com/questions/43601", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13562/" ]
Ok for subdomain it's easy. I guess it just looks up the subdomain: `blog5.site.com` => `explode('.', $_SERVER['REQUEST_URI'])...` But how does it do it for sub-directory setups? This should be interesting considering that pages, taxonomies and what not can take the first part of the part after the site domain name....
So, friend came up with a script for this. You put it in your root folder of your instal and it flips the values from one meta key to the other. I thought I'd share it in case anyone else need it. ``` <?php // Functions function db_connect($host,$db,$user,$pass){ if(@mysql_connect($host, $user, $pass)){ @mysq...
43,624
<p>Since 3.1 WordPress support multiple taxonomy query. The question is : If I have a two taxonomy query, e.g:</p> <pre><code>http://localhost:8888/site/?lot-term=australia&amp;story-type=note </code></pre> <p>how can I determine which template to be used for the query? On the first try, it loads taxonomy-lot-term.ph...
[ { "answer_id": 43632, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 3, "selected": true, "text": "<p><em>I'm not sure if this the best method, and I would like to hear some other suggestions!</em></p>\n\n<p>...
2012/02/27
[ "https://wordpress.stackexchange.com/questions/43624", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6383/" ]
Since 3.1 WordPress support multiple taxonomy query. The question is : If I have a two taxonomy query, e.g: ``` http://localhost:8888/site/?lot-term=australia&story-type=note ``` how can I determine which template to be used for the query? On the first try, it loads taxonomy-lot-term.php, but after I re install the ...
*I'm not sure if this the best method, and I would like to hear some other suggestions!* This will alter the template to some pre-defined template if two or more taxonomies are being queried. You can hard-code the taxonomies to check or use [`get_taxonomies`](http://codex.wordpress.org/Function_Reference/get_taxonomie...
43,627
<p>Since 3.3 we can enqueue scripts conditionally right in our shortcode functions, but when I tried to do this with some PHP class (uses <code>session_start()</code> in the <code>__construct()</code> function) as you can guess it gives me the <code>headers already sent</code> error.</p> <p>The problem is (this is usi...
[ { "answer_id": 43642, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 1, "selected": false, "text": "<p>You can try to use <code>the_posts</code> filter to search for you shortcode and require the sdk, something l...
2012/02/27
[ "https://wordpress.stackexchange.com/questions/43627", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2415/" ]
Since 3.3 we can enqueue scripts conditionally right in our shortcode functions, but when I tried to do this with some PHP class (uses `session_start()` in the `__construct()` function) as you can guess it gives me the `headers already sent` error. The problem is (this is using the [Facebook PHP SDK in conjunction wit...
I ended up solving this myself, but with help from @Bainternet (checking if shortcode is present in the post content). What I did was created a variable in my class called `facebook`, where I store the PHP SDK class. I used the `wp` hook to start the Facebook class if a few things are set and correct, this hook is all...
43,628
<p>Sorry for my bad english.<br> I have WP 3.3.1 &amp; wp-e-commerce.3.8.7.6.2. On the products page (which use wpsc-products_page.php template) I have list of products. I want to group this products by category. For example:</p> <p><em>*</em>*Cat1<br> Product 1<br> Product 2<br></p> <p>*<em>*</em> Cat2<br> Product 1...
[ { "answer_id": 44106, "author": "Subharanjan", "author_id": 13615, "author_profile": "https://wordpress.stackexchange.com/users/13615", "pm_score": -1, "selected": false, "text": "<p>Here you can find a solution : <a href=\"http://subharanjan.in/category-wise-products-display-in-wp-e-com...
2012/02/27
[ "https://wordpress.stackexchange.com/questions/43628", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13568/" ]
Sorry for my bad english. I have WP 3.3.1 & wp-e-commerce.3.8.7.6.2. On the products page (which use wpsc-products\_page.php template) I have list of products. I want to group this products by category. For example: *\**\*Cat1 Product 1 Product 2 \**\** Cat2 Product 1 Product 2 \**\** Cat3 Prod...
You are very close. I had the same problem a while ago, and [blogged about it](http://snippets.webaware.com.au/snippets/sort-wp-e-commerce-products-by-category-and-product-title/). Your join is missing one more join table, wp\_terms, which has the term you want to sort on. Here is the code I used: ``` class OrderWpsc...
43,630
<p>How do i add the light box function</p> <blockquote> <p>rel="lightbox"</p> </blockquote> <p>to the code below</p> <pre><code>&lt;a href="&lt;?php echo wp_get_attachment_url($post-&gt;ID); ?&gt;" title="&lt;?php echo wp_specialchars( get_the_title($post-&gt;ID), 1 ) ?&gt;"&gt;&lt;?php echo wp_get_attachment_imag...
[ { "answer_id": 43661, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 2, "selected": false, "text": "<p>i think most lightbox plugins require the rel or class attribute to be on the link, so:</p>\n\n<pre><code...
2012/02/27
[ "https://wordpress.stackexchange.com/questions/43630", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13556/" ]
How do i add the light box function > > rel="lightbox" > > > to the code below ``` <a href="<?php echo wp_get_attachment_url($post->ID); ?>" title="<?php echo wp_specialchars( get_the_title($post->ID), 1 ) ?>"><?php echo wp_get_attachment_image($post->ID, 'large' ); ?></a> ```
i think most lightbox plugins require the rel or class attribute to be on the link, so: ``` <a href="<?php echo wp_get_attachment_url($post->ID); ?>" rel="lightbox" title="<?php echo wp_specialchars( get_the_title($post->ID), 1 ) ?>"><?php echo wp_get_attachment_image($post->ID, 'large' ); ?></a> ```
43,645
<p>So with my blog i have a photo attachment page but it only shows to photo's at a time, and those two photo's are used as the navigation and i hate that.</p> <p>I want the attachment page to show all the photo's that goes along with the rest of that set. </p> <p>Here is the current code</p> <pre><code> &lt;...
[ { "answer_id": 43651, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 2, "selected": false, "text": "<p>Your code and description seem to refer to the <em>previous/next attachment <strong>navigation</em></strong...
2012/02/27
[ "https://wordpress.stackexchange.com/questions/43645", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13556/" ]
So with my blog i have a photo attachment page but it only shows to photo's at a time, and those two photo's are used as the navigation and i hate that. I want the attachment page to show all the photo's that goes along with the rest of that set. Here is the current code ``` <div id="nav-images" class="navi...
Your code and description seem to refer to the *previous/next attachment **navigation***. That code is intended to display *previous/next attachment navigation*, and that's exactly what it's doing. If you want to display all attachments: 1. Within the Post Content, use [the `[gallery]` shortcode](http://codex.wordpre...
43,647
<p>Is it possible to print two different url's from the same featured image/thumbnail?</p> <p>So i have set up my image size..</p> <pre><code>add_image_size( 'full-size', 460, 9999 ); add_image_size('fixed-height', NULL, 75, false); </code></pre> <p>I need to pull the url of these two images sizes into the post lik...
[ { "answer_id": 43651, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 2, "selected": false, "text": "<p>Your code and description seem to refer to the <em>previous/next attachment <strong>navigation</em></strong...
2012/02/27
[ "https://wordpress.stackexchange.com/questions/43647", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7384/" ]
Is it possible to print two different url's from the same featured image/thumbnail? So i have set up my image size.. ``` add_image_size( 'full-size', 460, 9999 ); add_image_size('fixed-height', NULL, 75, false); ``` I need to pull the url of these two images sizes into the post like so.. ``` <li><img src="full-si...
Your code and description seem to refer to the *previous/next attachment **navigation***. That code is intended to display *previous/next attachment navigation*, and that's exactly what it's doing. If you want to display all attachments: 1. Within the Post Content, use [the `[gallery]` shortcode](http://codex.wordpre...
43,662
<p>I am reading the source of a plugin (gallery to slideshow plugin) to make it behave like i want and it is using an action </p> <pre><code>add_action( 'the_posts', array( &amp;$this, 'have_gallery' ), 10, 1 ); </code></pre> <p>I want to know what those extra parameters (10,1) mean but i cant find the documentation ...
[ { "answer_id": 43663, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 3, "selected": true, "text": "<p>those parameters aren't unique to the_posts, they're parameters for the add_action() function</p>\n\n<pre>...
2012/02/27
[ "https://wordpress.stackexchange.com/questions/43662", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9335/" ]
I am reading the source of a plugin (gallery to slideshow plugin) to make it behave like i want and it is using an action ``` add_action( 'the_posts', array( &$this, 'have_gallery' ), 10, 1 ); ``` I want to know what those extra parameters (10,1) mean but i cant find the documentation of this action. Please help
those parameters aren't unique to the\_posts, they're parameters for the add\_action() function ``` add_action( $tag, $function_to_add, $priority, $accepted_args ); ``` the 10 is just the default priority and 1 is the default number of accepted arguments. since they're both default, you don't really need either. ...
43,670
<p>I need to build several highly customized WordPress instances beyond look and feel changes. For example, in one of the instances, any categories with children need to display in its own dropdown on the post edit page. I can not use multi-site setup as each instances may need to be highly customized.</p> <p>I woul...
[ { "answer_id": 43680, "author": "GavinR", "author_id": 2001, "author_profile": "https://wordpress.stackexchange.com/users/2001", "pm_score": 1, "selected": false, "text": "<p>My suggestion would be to do all your customization through <a href=\"http://codex.wordpress.org/Theme_Developmen...
2012/02/27
[ "https://wordpress.stackexchange.com/questions/43670", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12388/" ]
I need to build several highly customized WordPress instances beyond look and feel changes. For example, in one of the instances, any categories with children need to display in its own dropdown on the post edit page. I can not use multi-site setup as each instances may need to be highly customized. I would also like ...
As mentioned before, never, ever, modify wordpress core files. It is a maintenance nightmare and a security risk, and very, very bad practice. During development the only area you need concern yourself with is the wp-content folder, specifically plugins and themes. Put post type registrations, url rewrites, custom tax...
43,672
<p>I'm creating a child theme for the first time and I had a few questions regarding code added to header. </p> <p>In a non child theme there is certain code I add to my header.php file such as google analytics, google webmaster tools, buy sell ads, Facebook open graph, etc....</p> <p>How do you do this in a child th...
[ { "answer_id": 43674, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 6, "selected": true, "text": "<p>I would hook into the <code>wp_head</code> action. I would place this in a plugin so as to abstract it from ...
2012/02/27
[ "https://wordpress.stackexchange.com/questions/43672", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13390/" ]
I'm creating a child theme for the first time and I had a few questions regarding code added to header. In a non child theme there is certain code I add to my header.php file such as google analytics, google webmaster tools, buy sell ads, Facebook open graph, etc.... How do you do this in a child theme? Do you creat...
I would hook into the `wp_head` action. I would place this in a plugin so as to abstract it from your presentation layer. This allows for scalability and changing of themes. This also prevents any analytics collateral damage if a step is missed in migration from one theme to the next. ``` add_action('wp_head', 'wpse_4...
43,688
<p>I am in the process of migrating my site out of Wordpress and I need to filter the registration and/or login process so there is a separate database field that holds the user password in a hash that can be easily used on a non-WP site.</p> <p>How can I go about this?</p>
[ { "answer_id": 43693, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 2, "selected": false, "text": "<p>Because hashing is a one way procedure, to convert to MD5 you have 2 choices:</p>\n\n<ul>\n<li>Ask users to r...
2012/02/27
[ "https://wordpress.stackexchange.com/questions/43688", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12476/" ]
I am in the process of migrating my site out of Wordpress and I need to filter the registration and/or login process so there is a separate database field that holds the user password in a hash that can be easily used on a non-WP site. How can I go about this?
It is possible to write code to grab the user's password on login and write it out in a different format to a different location. Over time, you would thus accumulate the passwords in a different format than WordPress itself uses (it makes use of the excellent [PHPass library](http://www.openwall.com/phpass/) for passw...
43,705
<p>I created a mobile version of my site with CSS, with all my styles in a single stylesheet (using <code>@media only screen and (max-width: 480px), only screen and (max-device-width: 480px)</code> to define mobile styles). When it's all in a single stylesheet, it works fine.</p> <p>But I want to allow users to switch...
[ { "answer_id": 43746, "author": "Kelley van Evert", "author_id": 13605, "author_profile": "https://wordpress.stackexchange.com/users/13605", "pm_score": 1, "selected": false, "text": "<p>Wouldn't it be enough to switch mobile/desktop via a $_SESSION variable, make the \"switch to desktop...
2012/02/27
[ "https://wordpress.stackexchange.com/questions/43705", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13594/" ]
I created a mobile version of my site with CSS, with all my styles in a single stylesheet (using `@media only screen and (max-width: 480px), only screen and (max-device-width: 480px)` to define mobile styles). When it's all in a single stylesheet, it works fine. But I want to allow users to switch back to standard vie...
Wouldn't it be enough to switch mobile/desktop via a $\_SESSION variable, make the "switch to desktop link" include something like `?switchtodesktop=1` and have the header contain something like ``` session_start(); if ($_GET['switchtodesktop']) { $_SESSION['switchtodesktop'] = true; } $desktop = isset($_SESSION['sw...
43,706
<p>My post has only one category. The following code:</p> <pre><code>$categories = get_the_category(); </code></pre> <p>gives me this result:</p> <pre><code>Array ( [0] =&gt; stdClass Object ( [term_id] =&gt; 22 [name] =&gt; Style Guide [slug] =&gt; style-guide ...
[ { "answer_id": 43707, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 2, "selected": false, "text": "<p><code>$categories[$i]-&gt;count</code> and <code>$categories[$i]-&gt;category_count</code> are the number of ...
2012/02/27
[ "https://wordpress.stackexchange.com/questions/43706", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1447/" ]
My post has only one category. The following code: ``` $categories = get_the_category(); ``` gives me this result: ``` Array ( [0] => stdClass Object ( [term_id] => 22 [name] => Style Guide [slug] => style-guide [term_group] => 0 [term_taxonomy...
I'm guessing you're referring to the ``` [category_count] => 2 ``` when you say "saying that I have two categories"? If so, you should understand that category\_count is not the number of cateogries that this post has, but rather it is 'the number of uses of this category (also stored as 'count')' - see [get\_the\...
43,716
<p>WP 3.3.1, Suffusion 4.0.2</p> <p>I am trying to figure out how to make my front page display only the most recent post marked sticky. I can't find how to do this in the documentation.</p> <p>What I'm trying to do is use a combination of future post publication dates and expirations (via the Atropos plugin) to con...
[ { "answer_id": 43720, "author": "cmegown", "author_id": 13252, "author_profile": "https://wordpress.stackexchange.com/users/13252", "pm_score": 3, "selected": true, "text": "<p>If I'm understanding you correctly, you want to show only the most recent sticky post only on the front page. I...
2012/02/27
[ "https://wordpress.stackexchange.com/questions/43716", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13596/" ]
WP 3.3.1, Suffusion 4.0.2 I am trying to figure out how to make my front page display only the most recent post marked sticky. I can't find how to do this in the documentation. What I'm trying to do is use a combination of future post publication dates and expirations (via the Atropos plugin) to control what shows up...
If I'm understanding you correctly, you want to show only the most recent sticky post only on the front page. I had the same issue a month or two ago, and got some fantastic help from the community here at WordPress Answers. The solution is to run two loops in your index.php file. One to pull only the most recent stick...
43,737
<p>I currently have the following query:</p> <pre><code>$args = array( 'post_type' =&gt; 'post', 'orderby' =&gt; 'title', 'order' =&gt; 'ASC', 'posts_per_page' =&gt; 10, ); $my_query = new WP_Query($args); while ($my_query-&gt;have_posts()) : ...
[ { "answer_id": 43739, "author": "Rachel Baker", "author_id": 8054, "author_profile": "https://wordpress.stackexchange.com/users/8054", "pm_score": 5, "selected": true, "text": "<p>You can add post_status to your query, the string 'any' will return all posts no matter the status, or you c...
2012/02/27
[ "https://wordpress.stackexchange.com/questions/43737", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12476/" ]
I currently have the following query: ``` $args = array( 'post_type' => 'post', 'orderby' => 'title', 'order' => 'ASC', 'posts_per_page' => 10, ); $my_query = new WP_Query($args); while ($my_query->have_posts()) : $my_query->the_post(); ?> ``...
You can add post\_status to your query, the string 'any' will return all posts no matter the status, or you can use an array to just grab those you want. ``` $args = array( 'post_type' => 'post', 'orderby' => 'title', 'order' => 'ASC', 'post_status' => 'an...
43,780
<p>I'm trying to compare the permalink with a url and then output stuff depending if they match. At the moment I have the code below. On the page it's visibly showing that the permalink and the url (i.e $company) match yet it's outputting "don't show news articles".</p> <p>Where am I going wrong?</p> <pre><code>&lt;p...
[ { "answer_id": 49467, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 2, "selected": false, "text": "<p>Yes, it is entirely possible (and in fact, I am in the process of doing the same conversion).</p>\n\n<ol>\n...
2012/02/28
[ "https://wordpress.stackexchange.com/questions/43780", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4588/" ]
I'm trying to compare the permalink with a url and then output stuff depending if they match. At the moment I have the code below. On the page it's visibly showing that the permalink and the url (i.e $company) match yet it's outputting "don't show news articles". Where am I going wrong? ``` <p>permalink of current pa...
Konstantin Kovshenin from Automattic built a [small WP plugin](http://kovshenin.com/2012/convert-nextgen-galleries-to-wordpress-galleries/) hosted [here at GitHUB](https://github.com/kovshenin/escape-ngg), which does pretty much exactly what you are asking for. It does not seem to solve the whole migration as it works ...