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
39,500
<p>I've been combing this site and google for the answer and I've come up completely empty. Basically I want to do exactly what <a href="https://wordpress.stackexchange.com/questions/5308/custom-post-types-taxonomies-and-permalinks">this post</a> asks, but I need a hierarchical taxonomy. The answer given in that post...
[ { "answer_id": 39862, "author": "Jeff", "author_id": 11711, "author_profile": "https://wordpress.stackexchange.com/users/11711", "pm_score": 7, "selected": true, "text": "<p>After combining a bunch of pieces of other answers I got it working! So here's the solution for those of you who ...
2012/01/20
[ "https://wordpress.stackexchange.com/questions/39500", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11711/" ]
I've been combing this site and google for the answer and I've come up completely empty. Basically I want to do exactly what [this post](https://wordpress.stackexchange.com/questions/5308/custom-post-types-taxonomies-and-permalinks) asks, but I need a hierarchical taxonomy. The answer given in that post works great, bu...
After combining a bunch of pieces of other answers I got it working! So here's the solution for those of you who are struggling with this too: [This post](https://wordpress.stackexchange.com/questions/5308/custom-post-types-taxonomies-and-permalinks) and [this one](https://wordpress.stackexchange.com/questions/28979/h...
39,501
<p>I have downloaded a wordpress theme called livepuse, and unfortunately the alt tags are not showing on portfolio pages for my images. The website is as follows: <a href="http://vitul3ddesigns.com/project/listed-buildings/" rel="nofollow">http://vitul3ddesigns.com/project/listed-buildings/</a></p> <p>the code snippe...
[ { "answer_id": 39505, "author": "Shoebox", "author_id": 8776, "author_profile": "https://wordpress.stackexchange.com/users/8776", "pm_score": 0, "selected": false, "text": "<p>@Luke Tulley</p>\n\n<p>From your code it seems the alt tags are there but are empty, there are a number of ways ...
2012/01/20
[ "https://wordpress.stackexchange.com/questions/39501", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12254/" ]
I have downloaded a wordpress theme called livepuse, and unfortunately the alt tags are not showing on portfolio pages for my images. The website is as follows: <http://vitul3ddesigns.com/project/listed-buildings/> the code snippet from the theme is as follows: ``` <div class="thumbs"> ...
``` alt="<?php echo get_post_meta($att, '_wp_attachment_image_alt', true); ?>" ``` This should do the trick. The alt of an image is set in a custom meta field called "\_wp\_attachment\_image\_alt".
39,520
<p>i'm using contact form 7 plugin in wordpress,<br> i have generate text field like this: </p> <pre><code> [textarea your-message 25x3 "&lt;?php print_r($_POST); ?&gt;"] </code></pre> <p>i have to set value of input name which comes from another form with POST method. but it's not worked, instead of input tag, it...
[ { "answer_id": 39521, "author": "Mircea Sandu", "author_id": 12265, "author_profile": "https://wordpress.stackexchange.com/users/12265", "pm_score": 1, "selected": false, "text": "<p>Try using jQuery for this, something like</p>\n\n<pre><code>&lt;?php $name = $_GET['name']; ?&gt;\n&lt;sc...
2012/01/20
[ "https://wordpress.stackexchange.com/questions/39520", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12263/" ]
i'm using contact form 7 plugin in wordpress, i have generate text field like this: ``` [textarea your-message 25x3 "<?php print_r($_POST); ?>"] ``` i have to set value of input name which comes from another form with POST method. but it's not worked, instead of input tag, it displays `; ?>"]` there is any so...
Try using jQuery for this, something like ``` <?php $name = $_GET['name']; ?> <script type="text/javascript"> $(document).ready(function(){ var yourget = '<?php echo $name; ?>'; $('input[name="nameofyourfield"]').val(yourget); )}; </script> ```
39,522
<p>I have a basic admin top-level plugin I wrote which has a submenu driving a php form with a grid table populated from wp_dbase (from a custom table 'Branches' in it).</p> <p>My installation is a <em>clean</em> WP 3.3.1 on WAMPServer. Only changes are including the before the wp_head function in the , in the header...
[ { "answer_id": 39541, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 2, "selected": false, "text": "<p>It is important, that you include your script with wp_enqueue_script() and defined the scripts, there are use your...
2012/01/20
[ "https://wordpress.stackexchange.com/questions/39522", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12192/" ]
I have a basic admin top-level plugin I wrote which has a submenu driving a php form with a grid table populated from wp\_dbase (from a custom table 'Branches' in it). My installation is a *clean* WP 3.3.1 on WAMPServer. Only changes are including the before the wp\_head function in the , in the header file for both 2...
It is important, that you include your script with wp\_enqueue\_script() and defined the scripts, there are use your script. WP control the scripts. Your example has the problem, that your div and js inlcude this load before load jquiry and ui. Also it is possible, that WP load al scripts in Footer and then have you al...
39,525
<p>I am using the Latest News plugin (made by James Piggot, plugin website is <a href="http://chorosdesign.com/wordpress/plugins/" rel="nofollow">here</a>) and I have inserted code that displays 5 of the latest news items in the sidebar area.</p> <p>It's working fine, and displays all I need it to display. However, I ...
[ { "answer_id": 39549, "author": "Andrew", "author_id": 8598, "author_profile": "https://wordpress.stackexchange.com/users/8598", "pm_score": 0, "selected": false, "text": "<p>I like the \"News-Ticker\" plugin by Daniel Sachs. It allows for choice of number of posts, except length, and a ...
2012/01/20
[ "https://wordpress.stackexchange.com/questions/39525", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12267/" ]
I am using the Latest News plugin (made by James Piggot, plugin website is [here](http://chorosdesign.com/wordpress/plugins/)) and I have inserted code that displays 5 of the latest news items in the sidebar area. It's working fine, and displays all I need it to display. However, I want to be able to display the first...
If you go into your /wp-content/plugins directory, and edit the `latest-news.php` file, on line 85 change: ``` <?php the_content('read more...');?> ``` ... to: ``` <?php the_excerpt('read more...');?> ``` Note that modifying plugins is risky, because if you do an automatic update of the plugin after this, your ch...
39,529
<p>I'm a wordpress noob tweaking a theme, so I'm trying to understand how it works. I've read about 10 related posts in SE but don't get it yet. My problem is as follows:</p> <p>header.php seems to generate the menu with,</p> <pre><code>&lt;?php wp_nav_menu(array('theme_location' =&gt; 'nav-menu','container' =&gt;...
[ { "answer_id": 39533, "author": "Sufiyan Ghori", "author_id": 12276, "author_profile": "https://wordpress.stackexchange.com/users/12276", "pm_score": 0, "selected": false, "text": "<p>The menu can easily be generated using this code,</p>\n\n<pre><code>&lt;ul&gt;\n &lt;li &...
2012/01/20
[ "https://wordpress.stackexchange.com/questions/39529", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12273/" ]
I'm a wordpress noob tweaking a theme, so I'm trying to understand how it works. I've read about 10 related posts in SE but don't get it yet. My problem is as follows: header.php seems to generate the menu with, ``` <?php wp_nav_menu(array('theme_location' => 'nav-menu','container' => 'div', 'container_class' => 'me...
To get this to work you need to go to the menu admin and on the pages section click the tab that says *'view all'*. At the top of the list is a special option for your home page, whether it's the normal blog view or a specific page. Add that to the menu and you're good. ![enter image description here](https://i.stack....
39,543
<p>I am trying to stop latest blog items from displaying in the blog section of my site. I have used the following code:</p> <pre><code> &lt;?php if ( is_page('blog') ) { ?&gt; &lt;h2&gt;Don't display anything&lt;/h2&gt; &lt;?php } /* for all other pages */ else { ?&gt; &lt;h2&gt;Display b...
[ { "answer_id": 39551, "author": "OleVik", "author_id": 2983, "author_profile": "https://wordpress.stackexchange.com/users/2983", "pm_score": 2, "selected": true, "text": "<p>Assuming that the <code>'blog'</code> slug is correct, your code would work. I would suggest making a separate tem...
2012/01/20
[ "https://wordpress.stackexchange.com/questions/39543", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12267/" ]
I am trying to stop latest blog items from displaying in the blog section of my site. I have used the following code: ``` <?php if ( is_page('blog') ) { ?> <h2>Don't display anything</h2> <?php } /* for all other pages */ else { ?> <h2>Display blog</h2> <?php } ?> ``` However, whene...
Assuming that the `'blog'` slug is correct, your code would work. I would suggest making a separate template for the page, namely page-blog.php (see <http://codex.wordpress.org/images/1/18/Template_Hierarchy.png> and <http://codex.wordpress.org/Template_Hierarchy>) where you set up the structure and appearance of the p...
39,553
<p>I'm trying to add a custom body class to WordPress which should be the author of the post which is displayed. I looked at different how to's and tried to create some code but it doesn't work:</p> <pre><code>add_filter( 'body_class' , 'ft_add_guest_body_class' ); function ft_add_guest_body_class( $classes ) { ...
[ { "answer_id": 39556, "author": "Chris Cox", "author_id": 1718, "author_profile": "https://wordpress.stackexchange.com/users/1718", "pm_score": 0, "selected": false, "text": "<p>It's because you're trying to use get_the_author() outside of the Loop. Try using $post->post_author instead, ...
2012/01/20
[ "https://wordpress.stackexchange.com/questions/39553", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19458/" ]
I'm trying to add a custom body class to WordPress which should be the author of the post which is displayed. I looked at different how to's and tried to create some code but it doesn't work: ``` add_filter( 'body_class' , 'ft_add_guest_body_class' ); function ft_add_guest_body_class( $classes ) { // add 'wp_adm...
``` $author = $wp_query->post->post_author; $author = get_user_by('id', $author); author->user_nicename; ``` That should get you the author slug which you can use in your conditional statement. get\_the\_author can only be used inside the loop.
39,577
<p>I have the following code:</p> <p> </p> <pre><code> &lt;?php while (have_posts()) : the_post(); if(get_the_title() == 'Archive') query_posts('posts_per_page=1&amp;cat=1'); $category = get_the_category(); if ($category[0]-&gt;name) echo '&lt;h1&gt;'.$category[0]-&gt;n...
[ { "answer_id": 39584, "author": "Sufiyan Ghori", "author_id": 12276, "author_profile": "https://wordpress.stackexchange.com/users/12276", "pm_score": 0, "selected": false, "text": "<p>what i understood from your code is,\nyou are trying to get the attachment from the particular post,</p>...
2012/01/20
[ "https://wordpress.stackexchange.com/questions/39577", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12011/" ]
I have the following code: ``` <?php while (have_posts()) : the_post(); if(get_the_title() == 'Archive') query_posts('posts_per_page=1&cat=1'); $category = get_the_category(); if ($category[0]->name) echo '<h1>'.$category[0]->name.'</h1>'; $attachments = get_childr...
Try this using the get\_children function: ``` global $post; $args = array( 'numberposts' => -1, 'order'=> 'ASC', 'post_mime_type' => 'image', 'post_parent' => $post->ID, 'post_status' => 'any', 'post_type' => 'attachment' ); $attachments = get_children($args); ``` Reference: <http://codex.wo...
39,594
<p>I am using the <code>*_add_form_fields</code> action to add fields to a custom taxonomy. One of those fields is a wp_editor().</p> <p>The problem I am facing is that when I output the WordPress editor on the page like so:</p> <pre><code>wp_editor('test', 'mydescription', array('textarea_name' =&gt; 'my_description...
[ { "answer_id": 39599, "author": "ractoon", "author_id": 12291, "author_profile": "https://wordpress.stackexchange.com/users/12291", "pm_score": 0, "selected": false, "text": "<p>According to the codex for <a href=\"http://codex.wordpress.org/Function_Reference/wp_editor\" rel=\"nofollow\...
2012/01/20
[ "https://wordpress.stackexchange.com/questions/39594", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6811/" ]
I am using the `*_add_form_fields` action to add fields to a custom taxonomy. One of those fields is a wp\_editor(). The problem I am facing is that when I output the WordPress editor on the page like so: ``` wp_editor('test', 'mydescription', array('textarea_name' => 'my_description')); ``` and then if I click in...
*tinyMCE* `<textarea>` element is initially unseen by the used serialize function: ``` $.post( ajaxurl, $('#addtag').serialize(), function(r) { // Content here. } }); ``` You will need to call `tinyMCE.triggerSave()` to make it visible. Below is a simple snippet that should do the trick: ``` jQ...
39,597
<p>I'm using categories and wp_query to create an "advanced search" feature on <a href="http://www.barbadospropertylist.com/advanced-search/" rel="nofollow">my website</a>. It was working great until recently I noticed that the pagination was broken. The following 2 links should demonstrate the problem:</p> <p>On page...
[ { "answer_id": 45327, "author": "Ole Henrik Skogstrøm", "author_id": 11552, "author_profile": "https://wordpress.stackexchange.com/users/11552", "pm_score": 2, "selected": false, "text": "<p>This might happen because you need to include the pagination information when you run custom quer...
2012/01/20
[ "https://wordpress.stackexchange.com/questions/39597", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1341/" ]
I'm using categories and wp\_query to create an "advanced search" feature on [my website](http://www.barbadospropertylist.com/advanced-search/). It was working great until recently I noticed that the pagination was broken. The following 2 links should demonstrate the problem: On page 1 I get 185 results: > > <http:...
This might happen because you need to include the pagination information when you run custom queries with query\_posts. Because custom query\_post commands ignore any default values of the query\_posts command. Here is an example of a query i have used to solve this problem in a simpler case (just to exclude a single c...
39,602
<p>I want to export and export only the Categories and their description using SQL. For now I've managed to retrieve them using this:</p> <pre><code>SELECT wp_term_taxonomy.description, wp_terms.term_id, wp_terms.name, wp_terms.slug FROM wp_term_taxonomy JOIN wp_terms ON ( wp_term_taxonomy.term_id ...
[ { "answer_id": 39607, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 1, "selected": false, "text": "<p>How about just backing up those two tables using phpMyAdmin as detailed in the <a href=\"http://codex.wordpre...
2012/01/20
[ "https://wordpress.stackexchange.com/questions/39602", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5910/" ]
I want to export and export only the Categories and their description using SQL. For now I've managed to retrieve them using this: ``` SELECT wp_term_taxonomy.description, wp_terms.term_id, wp_terms.name, wp_terms.slug FROM wp_term_taxonomy JOIN wp_terms ON ( wp_term_taxonomy.term_id = wp_terms.ter...
How about just backing up those two tables using phpMyAdmin as detailed in the [codex article on wordpress backups](http://codex.wordpress.org/WordPress_Backups)?
39,618
<p>I'm trying to create a page which display a few of sub pages (child pages), however if the page has not child I would like to display a message.</p> <p>I cannot get a query that allow me to do something like this:</p> <pre><code> if (Page has childs) { do this } else { display this } </code></pre> <p>A...
[ { "answer_id": 39619, "author": "Jared", "author_id": 2415, "author_profile": "https://wordpress.stackexchange.com/users/2415", "pm_score": 1, "selected": false, "text": "<p>What about using something like this (provided you have a way to get the ID of the page you are checking for child...
2012/01/20
[ "https://wordpress.stackexchange.com/questions/39618", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4907/" ]
I'm trying to create a page which display a few of sub pages (child pages), however if the page has not child I would like to display a message. I cannot get a query that allow me to do something like this: ``` if (Page has childs) { do this } else { display this } ``` Any help? Thanks in advanced
``` $args = array( 'post_status' => 'publish', 'post_parent' => $post_id ); $children = get_posts( $args ); if( count( $children ) > 0 ) { //has children } else { //does not have children } ``` Docs: [`get_posts()`](http://codex.wordpress.org/Template_Tags/get_posts) This should also allow you to ha...
39,622
<p>With the default wp_link_pages the current/active page number is not a link. I would like to find a code/hack which turns the current/active page into a link to the top of the page.</p> <p>I am already using a custom code for wp_link_pages which can be found below:</p> <pre><code>&lt;?php wp_link_pages(array( ...
[ { "answer_id": 39634, "author": "Joshua Abenazer", "author_id": 10251, "author_profile": "https://wordpress.stackexchange.com/users/10251", "pm_score": 3, "selected": true, "text": "<p>Doesn't look like there are proper hooks to modify the output as per your requirements. But you could w...
2012/01/20
[ "https://wordpress.stackexchange.com/questions/39622", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5205/" ]
With the default wp\_link\_pages the current/active page number is not a link. I would like to find a code/hack which turns the current/active page into a link to the top of the page. I am already using a custom code for wp\_link\_pages which can be found below: ``` <?php wp_link_pages(array( 'before' => '<p clas...
Doesn't look like there are proper hooks to modify the output as per your requirements. But you could write a function similar to `wp_link_pages()` and call that in your theme. The following function would do your trick. ``` function custom_link_pages($args = '') { $defaults = array( 'before' =...
39,630
<p>My Emacs org-mode projects get exported to XHTML files. I would like to loosely integrate them into my blog. In particular, I'd like to use the header (and possibly footer) from my theme in the XHTML file.</p> <p>Would it be possible to put something like <code>&lt;?php include("../blog-wp-content/themes/my-theme...
[ { "answer_id": 39641, "author": "Sufiyan Ghori", "author_id": 12276, "author_profile": "https://wordpress.stackexchange.com/users/12276", "pm_score": 0, "selected": false, "text": "<p>You can't include a PHP file in XHTML file, simply change your XHTML file extension to .php in order to ...
2012/01/21
[ "https://wordpress.stackexchange.com/questions/39630", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12299/" ]
My Emacs org-mode projects get exported to XHTML files. I would like to loosely integrate them into my blog. In particular, I'd like to use the header (and possibly footer) from my theme in the XHTML file. Would it be possible to put something like `<?php include("../blog-wp-content/themes/my-theme/header.php");?>` (t...
The key to answer was found on SO; here is the solution for my case: create a PHP file with the following: ``` <?php define('WP_USE_THEMES', false); require('path/to/your-wordpress-dir/wp-blog-header.php'); get_header(); ?> //Contents of the body of your XHTML page go here <?php get_footer(); ?> ``` Now you have an...
39,659
<p>I've got a simple custom page template with a form on it. This page can process the form itself, so the entered data gets submitted there as well, using POST. Submitting the form, however, results in a 404 in my blog's regular theme (default template). If I leave out all of the data entry elements in the form, so I'...
[ { "answer_id": 39663, "author": "Albin Joseph", "author_id": 8129, "author_profile": "https://wordpress.stackexchange.com/users/8129", "pm_score": 2, "selected": false, "text": "<p>Are you using any of the wordpress reserved words in your html form? If yes that will give you a 404 page e...
2012/01/21
[ "https://wordpress.stackexchange.com/questions/39659", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12310/" ]
I've got a simple custom page template with a form on it. This page can process the form itself, so the entered data gets submitted there as well, using POST. Submitting the form, however, results in a 404 in my blog's regular theme (default template). If I leave out all of the data entry elements in the form, so I'll ...
You need to change: ``` <form action="index.php" method="post"> ``` to: ``` <form action="" method="post"> ``` I'm guessing that this is just a test case, but be sure that your final template has calls to `wp_head` and `wp_footer` in there.
39,662
<p>I'm working on an ajax application that will be embedded in a wordpress page. The ajax app exchanges data with servlets running on tomcat. Now the servlets need a way to determine if a request comes from a user that is logged in to wordpress. And if the user is logged in, the servlets also must be able to determine ...
[ { "answer_id": 39668, "author": "FlashingCursor", "author_id": 9276, "author_profile": "https://wordpress.stackexchange.com/users/9276", "pm_score": 1, "selected": false, "text": "<p>You could do something like this on the non-wp pages:</p>\n\n<pre><code>&lt;?php\nrequire('./wp-blog-head...
2012/01/21
[ "https://wordpress.stackexchange.com/questions/39662", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12311/" ]
I'm working on an ajax application that will be embedded in a wordpress page. The ajax app exchanges data with servlets running on tomcat. Now the servlets need a way to determine if a request comes from a user that is logged in to wordpress. And if the user is logged in, the servlets also must be able to determine the...
WordPress already has an API built in via an XMLRPC server. Meaning, you can make an XMLRPC request from your java app and verify a username/password. Unfortunately, there's no way to just authenticate through it as is. That said, it's very easy to roll your own. Just hook into `xmlrpc_methods`, a filter, and add you...
39,689
<p>I am trying to fetch the uploaded images using the link URL (The Link URL option is available in the <strong>Add Media</strong> when we upload/insert media) and display it on web. I have gone through the methods <code>has_post_thumbnail</code> and <code>the_post_thumbnail</code> which are working perfect for me. Now...
[ { "answer_id": 39691, "author": "FlashingCursor", "author_id": 9276, "author_profile": "https://wordpress.stackexchange.com/users/9276", "pm_score": 0, "selected": false, "text": "<p>I think what you're looking for is either wp_get_attachment_image : <a href=\"http://codex.wordpress.org...
2012/01/21
[ "https://wordpress.stackexchange.com/questions/39689", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12316/" ]
I am trying to fetch the uploaded images using the link URL (The Link URL option is available in the **Add Media** when we upload/insert media) and display it on web. I have gone through the methods `has_post_thumbnail` and `the_post_thumbnail` which are working perfect for me. Now, i am trying to display images (other...
> > I want to fetch that uploaded image re-size it into a thumbnail and > display it on the browser when i publish it..all of this > programmatically.. is there a way to do it? > > > You don't need to do this manually. The [add\_image\_size()](http://codex.wordpress.org/Function_Reference/add_image_size) functio...
39,693
<p>I have a few default widgets which I am using in a custom sidebar and I'd like to edit its output in my functions.php file. </p> <p>Currently the categories widget and blogrolls are generating an unordered list of links as such:</p> <pre><code>&lt;ul&gt; &lt;li class="cat-item cat-item-1"&gt; &lt;a href="http://lo...
[ { "answer_id": 39695, "author": "Jared", "author_id": 2415, "author_profile": "https://wordpress.stackexchange.com/users/2415", "pm_score": 1, "selected": false, "text": "<p>Here is a little jQuery snippet I made that should do what you want it to do (this just works for the category wid...
2012/01/21
[ "https://wordpress.stackexchange.com/questions/39693", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3093/" ]
I have a few default widgets which I am using in a custom sidebar and I'd like to edit its output in my functions.php file. Currently the categories widget and blogrolls are generating an unordered list of links as such: ``` <ul> <li class="cat-item cat-item-1"> <a href="http://localhost:8888/?cat=1">Uncategorized</...
Here is a little jQuery snippet I made that should do what you want it to do (this just works for the category widget): ``` // JavaScript Document $j = jQuery.noConflict(); $j(document).ready(function(){ $j('li.cat-item-1').parent().addClass('test'); }); ``` If you wanted to do this to all widgets, well it depen...
39,704
<p>Is there a way to display the comment field first and then the Name / Email / Website fields? I am using </p> <pre><code>&lt;?php comment_form( ); ?&gt; </code></pre> <p>in my theme. I am not looking for a CSS solution. </p>
[ { "answer_id": 39762, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 1, "selected": true, "text": "<p>Some loose implementation of where I would start. The hooks <code>'comment_form_default_fields'</code>, <code>...
2012/01/21
[ "https://wordpress.stackexchange.com/questions/39704", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10595/" ]
Is there a way to display the comment field first and then the Name / Email / Website fields? I am using ``` <?php comment_form( ); ?> ``` in my theme. I am not looking for a CSS solution.
Some loose implementation of where I would start. The hooks `'comment_form_default_fields'`, `'comment_form_defaults'`, and the `'comment_form_{location}'` hooks look promising. Line 1569 of comment-template.php is doing the fields, and line 1575 is doing the main field, you might be able to "trick" wordpress into putt...
39,711
<p><strong>EDIT: Reworded the question for more clarity</strong></p> <p>I'm trying to sort by custom meta box data, which I am converting to a date using the <code>strtotime</code> function, but I'm having some difficulty.</p> <p>My chief problem seems to be a catch-22 with the <code>strtotime</code> function. If I ...
[ { "answer_id": 39712, "author": "Jared", "author_id": 2415, "author_profile": "https://wordpress.stackexchange.com/users/2415", "pm_score": 4, "selected": true, "text": "<blockquote>\n <p><strong>EDIT:</strong> Your problem is this:</p>\n</blockquote>\n\n<p>When you save your meta data,...
2012/01/21
[ "https://wordpress.stackexchange.com/questions/39711", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5861/" ]
**EDIT: Reworded the question for more clarity** I'm trying to sort by custom meta box data, which I am converting to a date using the `strtotime` function, but I'm having some difficulty. My chief problem seems to be a catch-22 with the `strtotime` function. If I use `strtotime` inside the loop (see below) I cannot ...
> > **EDIT:** Your problem is this: > > > When you save your meta data, you want the date to be saved as a `strtotime()` date, but you want it to display the date back in the old `Y-m-d` format. What you need to do is save it as `strtotime()` and then when displaying the text back in the input, you need to reverse...
39,715
<p>I know that I can require all of the comments on my site to be moderated, but is there a way of forcing moderation for a specific custom post type (i.e. my CPT "species") whilst allowing instantaneous comments across the rest of the site?</p> <p>Thanks in advance,</p>
[ { "answer_id": 39712, "author": "Jared", "author_id": 2415, "author_profile": "https://wordpress.stackexchange.com/users/2415", "pm_score": 4, "selected": true, "text": "<blockquote>\n <p><strong>EDIT:</strong> Your problem is this:</p>\n</blockquote>\n\n<p>When you save your meta data,...
2012/01/21
[ "https://wordpress.stackexchange.com/questions/39715", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6344/" ]
I know that I can require all of the comments on my site to be moderated, but is there a way of forcing moderation for a specific custom post type (i.e. my CPT "species") whilst allowing instantaneous comments across the rest of the site? Thanks in advance,
> > **EDIT:** Your problem is this: > > > When you save your meta data, you want the date to be saved as a `strtotime()` date, but you want it to display the date back in the old `Y-m-d` format. What you need to do is save it as `strtotime()` and then when displaying the text back in the input, you need to reverse...
39,723
<p>I'm trying to unbind the click handler on post metaboxes so they no longer hide when the handle is clicked. I need to do this because I use the handle to contain <code>&lt;select&gt;</code> elements &amp; when changing these the <code>click</code> event is fired.</p> <p>The code that binds the click handler is here...
[ { "answer_id": 39725, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 3, "selected": true, "text": "<p>You can just put the necessary javascript in a file and enqueue it on the necessary page:</p>\n\n<pre><cod...
2012/01/22
[ "https://wordpress.stackexchange.com/questions/39723", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8230/" ]
I'm trying to unbind the click handler on post metaboxes so they no longer hide when the handle is clicked. I need to do this because I use the handle to contain `<select>` elements & when changing these the `click` event is fired. The code that binds the click handler is here: <https://github.com/WordPress/WordPress/...
You can just put the necessary javascript in a file and enqueue it on the necessary page: ``` add_action( 'admin_enqueue_scripts', 'add_admin_scripts', 10, 1 ); function add_admin_scripts( $hook ) { //You can globalise $post here and enqueue the script for only certain post-types. if ( $hook == 'post-new.php' ...
39,731
<p>I'm looking to display the following loop, only if a custom field data exists, if not, I don't want to display anything.</p> <pre><code> &lt;?php while (have_posts()) : the_post(); $data = get_post_meta( $post-&gt;ID, 'key', true );?&gt; &lt;!-- info --&gt; &lt;?php endwhile; ?&gt; </code></pre> <p>Any guessing...
[ { "answer_id": 39725, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 3, "selected": true, "text": "<p>You can just put the necessary javascript in a file and enqueue it on the necessary page:</p>\n\n<pre><cod...
2012/01/22
[ "https://wordpress.stackexchange.com/questions/39731", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4907/" ]
I'm looking to display the following loop, only if a custom field data exists, if not, I don't want to display anything. ``` <?php while (have_posts()) : the_post(); $data = get_post_meta( $post->ID, 'key', true );?> <!-- info --> <?php endwhile; ?> ``` Any guessing? Thanks in advanced.
You can just put the necessary javascript in a file and enqueue it on the necessary page: ``` add_action( 'admin_enqueue_scripts', 'add_admin_scripts', 10, 1 ); function add_admin_scripts( $hook ) { //You can globalise $post here and enqueue the script for only certain post-types. if ( $hook == 'post-new.php' ...
39,736
<p>I am new to Wordpress. I am using the free Theme for my blog. I have added Menu as About Us, Contact Us, Groups etc ..</p> <p>I need to add Static Pages to About Us, Contact Us etc ..!!</p> <p>I dont know to How to create and map it to the Menu !!</p>
[ { "answer_id": 39725, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 3, "selected": true, "text": "<p>You can just put the necessary javascript in a file and enqueue it on the necessary page:</p>\n\n<pre><cod...
2012/01/22
[ "https://wordpress.stackexchange.com/questions/39736", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3490/" ]
I am new to Wordpress. I am using the free Theme for my blog. I have added Menu as About Us, Contact Us, Groups etc .. I need to add Static Pages to About Us, Contact Us etc ..!! I dont know to How to create and map it to the Menu !!
You can just put the necessary javascript in a file and enqueue it on the necessary page: ``` add_action( 'admin_enqueue_scripts', 'add_admin_scripts', 10, 1 ); function add_admin_scripts( $hook ) { //You can globalise $post here and enqueue the script for only certain post-types. if ( $hook == 'post-new.php' ...
39,747
<p>I purchased the Nuke theme and added a custom page template using the code from page.php as a framework. The only code I added was a loop to pull 5 posts from category ID 12. I would like to add navigation buttons "Next and Previous" to view the rest of my posts in this category. What code do I need to add?</p> <p>...
[ { "answer_id": 39775, "author": "Jeremy Jared", "author_id": 5339, "author_profile": "https://wordpress.stackexchange.com/users/5339", "pm_score": 1, "selected": false, "text": "<p>Try using this for you page links.</p>\n\n<pre><code>&lt;span class='older'&gt;\n &lt;?php next_posts_link...
2012/01/22
[ "https://wordpress.stackexchange.com/questions/39747", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12334/" ]
I purchased the Nuke theme and added a custom page template using the code from page.php as a framework. The only code I added was a loop to pull 5 posts from category ID 12. I would like to add navigation buttons "Next and Previous" to view the rest of my posts in this category. What code do I need to add? View an ex...
Try using this for you page links. ``` <span class='older'> <?php next_posts_link('&amp;laquo; Newer Entries'); ?> </span> <span class='newer'> <?php previous_posts_link('Older Entries &amp;raquo;'); ?> </span> ```
39,765
<p>I have a php file in my server (say www.example.com/up/up.php). If i access that file through the url, my site says no page found. but i want to call that php file using url parameter. I want to call that file to a download file using url access( say www.example.com/up/up.php?f=207). can someone help me how to do t...
[ { "answer_id": 39768, "author": "Jared", "author_id": 2415, "author_profile": "https://wordpress.stackexchange.com/users/2415", "pm_score": 4, "selected": true, "text": "<p>What you can do is this:</p>\n\n<p>Put <code>up.php</code> in your active theme's folder, and put this line at the ...
2012/01/22
[ "https://wordpress.stackexchange.com/questions/39765", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12124/" ]
I have a php file in my server (say www.example.com/up/up.php). If i access that file through the url, my site says no page found. but i want to call that php file using url parameter. I want to call that file to a download file using url access( say www.example.com/up/up.php?f=207). can someone help me how to do this....
What you can do is this: Put `up.php` in your active theme's folder, and put this line at the top of your `up.php` file: ``` <?php /* Template Name: Up */ ?> ``` Create a page called Up in your WordPress Dashboard, then on the right side of the edit page screen, set the Template to 'Up'. Depending on what you are ...
39,766
<p>Alright, I was starting on the code for my blog today when I ran into a little issue. However, before I ask my question, it my help if I actually explain what the functionality I am hoping to achieve. (you can also view my header comp at <a href="http://louisstephens.cc/comps/blog.png" rel="nofollow">http://louisste...
[ { "answer_id": 39772, "author": "Jared", "author_id": 2415, "author_profile": "https://wordpress.stackexchange.com/users/2415", "pm_score": 0, "selected": false, "text": "<p>If you insist on showing all months, what I would do is use <a href=\"http://codex.wordpress.org/Function_Referenc...
2012/01/22
[ "https://wordpress.stackexchange.com/questions/39766", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/807/" ]
Alright, I was starting on the code for my blog today when I ran into a little issue. However, before I ask my question, it my help if I actually explain what the functionality I am hoping to achieve. (you can also view my header comp at <http://louisstephens.cc/comps/blog.png> ) In my header, I am going to have the y...
How about making an array of months and then getting the posts per-month? Though I suspect this is somewhat less efficient than @Jared's... ``` function get_posts_grouped_by_month( $year = null ) { if ( $year == null ) { $year = date('Y'); } $months = range(1,12); $posts = array(); forea...
39,777
<p>When rotating an image with the WordPress image editor it creates new images and renames all of the images for the thumbnail, medium and large image sizes that are default for WordPress.</p> <p>My problem is that I have registered new image sizes using add_image_size();</p> <p>Is there anyway to make WordPress ren...
[ { "answer_id": 40013, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 2, "selected": true, "text": "<p>From examination, it looks like a bug. I can't think of a good reason it shouldn't apply those changes.</p>\n\n<p>Re...
2012/01/22
[ "https://wordpress.stackexchange.com/questions/39777", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6811/" ]
When rotating an image with the WordPress image editor it creates new images and renames all of the images for the thumbnail, medium and large image sizes that are default for WordPress. My problem is that I have registered new image sizes using add\_image\_size(); Is there anyway to make WordPress rename/rotate thes...
From examination, it looks like a bug. I can't think of a good reason it shouldn't apply those changes. Reported: <http://core.trac.wordpress.org/ticket/19889> Patch in that ticket fixes the problem. Also, in response to your other question, you can define IMAGE\_EDIT\_OVERWRITE to true in the wp-config file to make...
39,798
<p>I want my thumbnails on a particular page to be <code>300px</code> &times; <code>100px</code>, exactly. Currently, images shrink until they hit the 300 pixel or 100 pixel mark. How do I get the image to crop to exactly 300 &times; 100 (preferably without image distortion).</p> <pre><code>// functions.php: if ( fu...
[ { "answer_id": 39801, "author": "krembo99", "author_id": 13256, "author_profile": "https://wordpress.stackexchange.com/users/13256", "pm_score": -1, "selected": false, "text": "<p>Try to Change the \"ture\" paramater to \"false\" .\nYou can also remove the \"if\" statements on the functi...
2012/01/23
[ "https://wordpress.stackexchange.com/questions/39798", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12051/" ]
I want my thumbnails on a particular page to be `300px` × `100px`, exactly. Currently, images shrink until they hit the 300 pixel or 100 pixel mark. How do I get the image to crop to exactly 300 × 100 (preferably without image distortion). ``` // functions.php: if ( function_exists( 'add_image_size' ) ) add_theme_supp...
Refer to [the **`add_image_size()`** Codex entry](http://codex.wordpress.org/Function_Reference/add_image_size): ``` <?php add_image_size( $name, $width, $height, $crop ); ?> ``` The **`$crop`** parameter is the key: > > *(boolean) (optional)* Crop the image or not. False - Soft proportional crop mode ; True - Har...
39,817
<p>I currently use the following code to list posts in Archive.php but I want the results to be ordered by name in ascending order, I have checked the codex but the answer isn't clear to me, how can I get this working?</p> <pre><code>&lt;?php $post = $posts[0]; // ?&gt; </code></pre> <p>Thanks in advance.</p>
[ { "answer_id": 39818, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 7, "selected": true, "text": "<p>The easiest way to do this is to use a hook (the <code>pre_get_posts</code> hook) to change the order. But...
2012/01/23
[ "https://wordpress.stackexchange.com/questions/39817", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11945/" ]
I currently use the following code to list posts in Archive.php but I want the results to be ordered by name in ascending order, I have checked the codex but the answer isn't clear to me, how can I get this working? ``` <?php $post = $posts[0]; // ?> ``` Thanks in advance.
The easiest way to do this is to use a hook (the `pre_get_posts` hook) to change the order. But you should check that the query is one for which you do want to alter the order! ([`is_archive()`](http://codex.wordpress.org/Function_Reference/is_archive) or [`is_post_type_archive()`](http://codex.wordpress.org/Function_R...
39,819
<p>So, i successfully managed to add a drop down option, the problem is when i click save all of the options are removed, however the chosen option is implemented successfully.</p> <p>Here is the relevant code:</p> <pre><code>function widget($args, $instance) { extract( $args ); $pfxattribution = $in...
[ { "answer_id": 39820, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 0, "selected": false, "text": "<p>Your <code>&lt;option&gt;</code>s need <code>value=</code> or they do not send any value...essentially right ...
2012/01/23
[ "https://wordpress.stackexchange.com/questions/39819", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12364/" ]
So, i successfully managed to add a drop down option, the problem is when i click save all of the options are removed, however the chosen option is implemented successfully. Here is the relevant code: ``` function widget($args, $instance) { extract( $args ); $pfxattribution = $instance['pfx-attributi...
Danny, this is pretty much lifted straight from a plug-in I've made: ``` <?php function form($instance){ $instance = wp_parse_args( (array) $instance, $this->w_arg ); ?> <p> <select id="<?php echo $this->get_field_id('order'); ?>" name="<?php echo $this->get_field_name('order'); ?>" type="text"> ...
39,830
<p>I need to hook a function only when I delete permanently a post from the database, I've tried the 'before_delete_post' hook, however, it's called both when it's trashed and permanently deleted.</p> <p>The wp_delete_post() function calls wp_trash_post() and should stop processing, but it looks like the wp_delete_pos...
[ { "answer_id": 39835, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 3, "selected": false, "text": "<p><code>before_delete_post</code> is not called when a post is only trashed. </p>\n\n<p>While <code>wp_dele...
2012/01/23
[ "https://wordpress.stackexchange.com/questions/39830", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6725/" ]
I need to hook a function only when I delete permanently a post from the database, I've tried the 'before\_delete\_post' hook, however, it's called both when it's trashed and permanently deleted. The wp\_delete\_post() function calls wp\_trash\_post() and should stop processing, but it looks like the wp\_delete\_post(...
The issue was the "Sitewide tags" plugin which was misbehaving the natural WP flow. A function called `sitewide_tags_post_delete()` is hooked on 'trash\_post' and it's calling `wp_delete_post()` to delete the post on the main blog. Following the @Stephen's approach, I did this: ``` add_action('before_delete_post', 'm...
39,840
<p>I'm trying to configure forums using the bbpress plugin that can only be viewed by logged in users. I attempted creating them as private but found that sub-forums don't show up on my root /forums page. Another forum suggested using is_user_logged_in() to determine whether or not forums are displayed.</p> <p>What is...
[ { "answer_id": 44515, "author": "jtotheh", "author_id": 8677, "author_profile": "https://wordpress.stackexchange.com/users/8677", "pm_score": 0, "selected": false, "text": "<p>The only way I've gotten around this so far is <a href=\"http://bbpress.trac.wordpress.org/browser/branches/plug...
2012/01/23
[ "https://wordpress.stackexchange.com/questions/39840", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12366/" ]
I'm trying to configure forums using the bbpress plugin that can only be viewed by logged in users. I attempted creating them as private but found that sub-forums don't show up on my root /forums page. Another forum suggested using is\_user\_logged\_in() to determine whether or not forums are displayed. What is the be...
The solution I went with was to create a file in my theme's folder named bbpress.php. I then copied the contents of my theme's page.php file into the new file and modified it to only show it's contents when a user is logged in. In my case it looked like the following: ``` if( is_user_logged_in() ) { get_template_p...
39,843
<p><em>Yes, i have found other questions to this topic, but no have the same topic exactly and no solution for my problem.</em> </p> <p>If you include code inside the html-tab and you switch to the visual mode, then format WP the code to a block, remove all breaks and leave lines, see the screenshots. I think this eas...
[ { "answer_id": 51538, "author": "jb510", "author_id": 2932, "author_profile": "https://wordpress.stackexchange.com/users/2932", "pm_score": 0, "selected": false, "text": "<p>I think the easiest solution for what you're describing is a plugin like: <a href=\"http://wordpress.org/extend/pl...
2012/01/23
[ "https://wordpress.stackexchange.com/questions/39843", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/170/" ]
*Yes, i have found other questions to this topic, but no have the same topic exactly and no solution for my problem.* If you include code inside the html-tab and you switch to the visual mode, then format WP the code to a block, remove all breaks and leave lines, see the screenshots. I think this easier to understand...
There is my solution - tehere is my solution of this problem: [Preserving tabs and line breaks in <pre><code> when switching from HTML to Visual Editor](https://wordpress.stackexchange.com/questions/45796/preserving-tabs-and-line-breaks-in-precode-when-switching-from-html-to-visua/73312#73312)
39,890
<p>Following the directions here <a href="http://codex.wordpress.org/AJAX_in_Plugins#Ajax_on_the_Administration_Side" rel="nofollow">http://codex.wordpress.org/AJAX_in_Plugins#Ajax_on_the_Administration_Side</a></p> <p>I wrote this code:</p> <p>EDITED TO INCLUDE DIE(), STILL NOT WORKING</p> <pre><code>function my_bu...
[ { "answer_id": 39892, "author": "Jared", "author_id": 2415, "author_profile": "https://wordpress.stackexchange.com/users/2415", "pm_score": 1, "selected": false, "text": "<blockquote>\n <p><strong>EDIT</strong>: I found several problems with your method.</p>\n</blockquote>\n\n<p>This is...
2012/01/23
[ "https://wordpress.stackexchange.com/questions/39890", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12288/" ]
Following the directions here <http://codex.wordpress.org/AJAX_in_Plugins#Ajax_on_the_Administration_Side> I wrote this code: EDITED TO INCLUDE DIE(), STILL NOT WORKING ``` function my_button() { echo "<script type = 'text/javascript'> function ajaxRequest(){ jQuery(document).ready(function(jQuery) { var...
Your url should be pointing to admin-ajax.php ``` echo admin_url('admin-ajax.php'); ```
39,891
<p>I'm trying to figure out how to best solve an issue I have with 3rd party API's (OG, Foursquare, Yelp, etc.). I use the transient API to call and store the various data in order to:</p> <ol> <li>Not exceed any API limits</li> <li>Increase load speed</li> </ol> <p>However, <strong>the issue arises when a new API ca...
[ { "answer_id": 39893, "author": "Rob Vermeer", "author_id": 11135, "author_profile": "https://wordpress.stackexchange.com/users/11135", "pm_score": 1, "selected": false, "text": "<p>You can set another transient on success with a long timeout. Then if the first one times out and you get ...
2012/01/23
[ "https://wordpress.stackexchange.com/questions/39891", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2393/" ]
I'm trying to figure out how to best solve an issue I have with 3rd party API's (OG, Foursquare, Yelp, etc.). I use the transient API to call and store the various data in order to: 1. Not exceed any API limits 2. Increase load speed However, **the issue arises when a new API call errors out** for whichever reason; e...
Mark Jaquith made a "TLC Transients" method that you might find useful. Essentially, it implements a transient interface that does soft expiration and background updating. <https://github.com/markjaquith/WP-TLC-Transients> The idea is that you define a function to do the call that gets the data, then define the trans...
39,918
<p>trying to insert content before the post content in my functions.php - I know how to use the regular wp hooks, but unsure how to insert into other areas.</p> <p>Tried this, but it kills content on any other post type:</p> <pre><code>function property_slideshow( $content ) { if ( is_single() &amp;&amp; 'property' ...
[ { "answer_id": 39920, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 7, "selected": true, "text": "<p>Just use the <code>the_content</code> filter, e.g.:</p>\n\n<pre><code>&lt;?php\nfunction theme_slug_filter_t...
2012/01/24
[ "https://wordpress.stackexchange.com/questions/39918", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4902/" ]
trying to insert content before the post content in my functions.php - I know how to use the regular wp hooks, but unsure how to insert into other areas. Tried this, but it kills content on any other post type: ``` function property_slideshow( $content ) { if ( is_single() && 'property' == get_post_type() ) { $c...
Just use the `the_content` filter, e.g.: ``` <?php function theme_slug_filter_the_content( $content ) { $custom_content = 'YOUR CONTENT GOES HERE'; $custom_content .= $content; return $custom_content; } add_filter( 'the_content', 'theme_slug_filter_the_content' ); ?> ``` Basically, you append the post co...
39,925
<p>I want a page to view only a specific post format (e.g. aside).</p> <p>Do I have to create my own page and run a custom query, or does Wordpress have an automatic page generated for me (like the categories)?</p>
[ { "answer_id": 39926, "author": "Jared", "author_id": 2415, "author_profile": "https://wordpress.stackexchange.com/users/2415", "pm_score": 1, "selected": false, "text": "<p>You would need to add theme support for post formats with code.</p>\n\n<pre><code>add_theme_support( 'post-formats...
2012/01/24
[ "https://wordpress.stackexchange.com/questions/39925", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12399/" ]
I want a page to view only a specific post format (e.g. aside). Do I have to create my own page and run a custom query, or does Wordpress have an automatic page generated for me (like the categories)?
Take a look at [get\_post\_format\_link()](http://codex.wordpress.org/Function_Reference/get_post_format_link) Here's a little example that uses `get_post_format_link()` to show a link to the format's archive page. You can see something similar to this in action on [Justin Tadlock's site](http://justintadlock.com/). ...
39,954
<p>Say I have a non-Wordpress website abc.com that has a Wordpress install at abc.com/news. </p> <p>How can I integrate my non-Wordpress login system at abc.com with the Wordpress installation at abc.com/news so that if a user logs into abc.com and then browses to abc.com/news he is already logged in at abc.com/news? ...
[ { "answer_id": 39964, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 0, "selected": false, "text": "<p>There are two basic methods that you can tackle this with</p>\n\n<ol>\n<li>Let wordpress handle all the user ...
2012/01/24
[ "https://wordpress.stackexchange.com/questions/39954", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12403/" ]
Say I have a non-Wordpress website abc.com that has a Wordpress install at abc.com/news. How can I integrate my non-Wordpress login system at abc.com with the Wordpress installation at abc.com/news so that if a user logs into abc.com and then browses to abc.com/news he is already logged in at abc.com/news?
Not tested, but try to do a post request via ajax. The file you call via ajax should look something like this: ``` require( dirname(__FILE__) . '/wp-load.php' ); $user = filter_input( INPUT_POST, FILTER_SANITIZE_STRING ); $pass = filter_input( INPUT_POST, FILTER_SANITIZE_STRING ); is_wp_error( wp_signon( ...
39,963
<p>I'm trying to set up a search page that first shows a Loop with all posts with a Custom Field meta_key of 'seek_premium' where it's meta_value is 'yes', and then a second Loop where the meta_value (same meta_key) is empty. I've got it working for the most part, but the way I'm doing it seems to break the default sea...
[ { "answer_id": 39966, "author": "Jared", "author_id": 2415, "author_profile": "https://wordpress.stackexchange.com/users/2415", "pm_score": 0, "selected": false, "text": "<p>Try this once and see if it makes a difference:</p>\n\n<pre><code>&lt;?php if (have_posts()) : ?&gt;\n&lt;h1&gt;My...
2012/01/24
[ "https://wordpress.stackexchange.com/questions/39963", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11952/" ]
I'm trying to set up a search page that first shows a Loop with all posts with a Custom Field meta\_key of 'seek\_premium' where it's meta\_value is 'yes', and then a second Loop where the meta\_value (same meta\_key) is empty. I've got it working for the most part, but the way I'm doing it seems to break the default s...
I've found what I needed here: <http://deadlyhifi.posterous.com/separate-posts-and-pages-in-wordpress-search> Essentially, I needed to know how to maintain the basic query WP generated (so it knew to keep it as a search result vs. just executing the exact query I was calling in the search.php file). Thanks everyone f...
39,977
<p>A funky cafe changes their menu every month, and they're not comfortable with using the default Wordpress editor to make a Wordpress page look the same as their Word doc. <a href="http://www.louisbaxters.com.au/Lunch_Menu.docx" rel="nofollow">Example word doc here</a>.</p> <p>Can you think of a way to get this men...
[ { "answer_id": 39997, "author": "Brooke.", "author_id": 2204, "author_profile": "https://wordpress.stackexchange.com/users/2204", "pm_score": 1, "selected": false, "text": "<p>Rock the <a href=\"http://codex.wordpress.org/Custom_Fields\" rel=\"nofollow\">custom fields</a>? You could do t...
2012/01/24
[ "https://wordpress.stackexchange.com/questions/39977", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3206/" ]
A funky cafe changes their menu every month, and they're not comfortable with using the default Wordpress editor to make a Wordpress page look the same as their Word doc. [Example word doc here](http://www.louisbaxters.com.au/Lunch_Menu.docx). Can you think of a way to get this menu to display nicely as HTML inside [t...
Rock the [custom fields](http://codex.wordpress.org/Custom_Fields)? You could do this manually or by using a plugin such as [magic fields](http://wordpress.org/extend/plugins/magic-fields-2/) or [PODS](http://wordpress.org/extend/plugins/pods/). I've never used PODS but I've been eying it for a while and think this m...
39,980
<p>i'm trying to achieve the following:</p> <p>user enters this URL into browser </p> <p><code>http://mydomain.com/boston/categoryname/postname/</code> </p> <p>i then want to get the first "folder" and check whether or not it's "boston" or "newyork" - if yes, then remove this part of the URL, add it as an query-para...
[ { "answer_id": 48620, "author": "Frank N", "author_id": 13561, "author_profile": "https://wordpress.stackexchange.com/users/13561", "pm_score": 0, "selected": false, "text": "<p>I am on similar turf. See:\n<a href=\"https://wordpress.stackexchange.com/questions/48481\">flexible rewrite &...
2012/01/24
[ "https://wordpress.stackexchange.com/questions/39980", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7076/" ]
i'm trying to achieve the following: user enters this URL into browser `http://mydomain.com/boston/categoryname/postname/` i then want to get the first "folder" and check whether or not it's "boston" or "newyork" - if yes, then remove this part of the URL, add it as an query-parameter and pass the modified URL on ...
i fixed it using the apache proxy module: ``` <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{QUERY_STRING} !location RewriteRule ^(boston|newyork)/$ /index.php?location=$1 [NC,QSA,P] RewriteCond %{QUERY_STRING} !location RewriteRule ^(boston|newyork)/(.*)$ /$2?location=$1 [NC,QSA,P] RewriteRu...
39,986
<p>I have the following code that generates a login form for every page in my blog.</p> <pre><code>&lt;form action="&lt;?php echo wp_login_url(); ?&gt;" method="post"&gt; username: &lt;br /&gt; &lt;input name="log" id="login_username" type="text" /&gt; &lt;br /&gt; password: &lt;br /&gt; &lt;input name="pwd" id="login...
[ { "answer_id": 39989, "author": "Jared", "author_id": 2415, "author_profile": "https://wordpress.stackexchange.com/users/2415", "pm_score": 3, "selected": false, "text": "<p>If you read the documentation on <a href=\"http://codex.wordpress.org/Function_Reference/wp_login_url\"><code>wp_l...
2012/01/24
[ "https://wordpress.stackexchange.com/questions/39986", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7410/" ]
I have the following code that generates a login form for every page in my blog. ``` <form action="<?php echo wp_login_url(); ?>" method="post"> username: <br /> <input name="log" id="login_username" type="text" /> <br /> password: <br /> <input name="pwd" id="login_password" type="password" /> <br /> <br /> <input na...
I should've just put a hidden input in the form with name of `login` and some value like `true`.
39,993
<p>How do I adapt this <a href="https://wordpress.stackexchange.com/questions/695/restricting-a-plugin-to-only-load-its-css-and-js-on-selected-pages">solution</a> to work with my plugin? (Please see the link).</p> <p>I enqueue my css and js script as follows:</p> <pre><code>function my_plugin_init() { wp_enqueue_scr...
[ { "answer_id": 40006, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 4, "selected": false, "text": "<h2>The right hooks</h2>\n\n<pre><code> // Use both for scripts &amp; styles *)\n wp_enqueue_scripts // (for the...
2012/01/24
[ "https://wordpress.stackexchange.com/questions/39993", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4509/" ]
How do I adapt this [solution](https://wordpress.stackexchange.com/questions/695/restricting-a-plugin-to-only-load-its-css-and-js-on-selected-pages) to work with my plugin? (Please see the link). I enqueue my css and js script as follows: ``` function my_plugin_init() { wp_enqueue_script('my_plugin_script', plugins_...
The right hooks --------------- ``` // Use both for scripts & styles *) wp_enqueue_scripts // (for the frontend) login_enqueue_scripts // (for the login screen) admin_enqueue_scripts // (for the admin dashboard) ``` \*) Read [this article @wpdevel](http://wpdevel.wordpress.com/2011/12/12/use-wp_enque...
39,994
<p>For a demo environment, I would like to pre-fill the username and password fields of the wp-login form with respectively "demo" and "demo" string.</p> <p>Thus users will just need to click on the "Log-in" button to connect to the admin area.</p> <p>There is a way to do that ? Maybe with a hook ?</p> <p>Thanks for...
[ { "answer_id": 39995, "author": "Brooke.", "author_id": 2204, "author_profile": "https://wordpress.stackexchange.com/users/2204", "pm_score": 2, "selected": false, "text": "<p>Here are 3 ways to do it:</p>\n\n<p>The first way is to use the <a href=\"http://codex.wordpress.org/Function_Re...
2012/01/24
[ "https://wordpress.stackexchange.com/questions/39994", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4552/" ]
For a demo environment, I would like to pre-fill the username and password fields of the wp-login form with respectively "demo" and "demo" string. Thus users will just need to click on the "Log-in" button to connect to the admin area. There is a way to do that ? Maybe with a hook ? Thanks for your advises
The Result ========== ![enter image description here](https://i.stack.imgur.com/swJK1.png) ### Username You can declare the form field value global and prefill it. > > This will override any setting done via the "Remember me"-Checkbox. > > > ``` /** * Changes the default user name to "DEMO" * * @return st...
39,996
<p>I modified a .po file, basically I opened as txt file and made the changes, however I uploaded it and is changes are not working.</p> <p>I wonder if I need an special software for doing and generate a new .mo each time I make a change, or what am I missing?</p> <p>Thank in advanced</p>
[ { "answer_id": 39995, "author": "Brooke.", "author_id": 2204, "author_profile": "https://wordpress.stackexchange.com/users/2204", "pm_score": 2, "selected": false, "text": "<p>Here are 3 ways to do it:</p>\n\n<p>The first way is to use the <a href=\"http://codex.wordpress.org/Function_Re...
2012/01/24
[ "https://wordpress.stackexchange.com/questions/39996", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4907/" ]
I modified a .po file, basically I opened as txt file and made the changes, however I uploaded it and is changes are not working. I wonder if I need an special software for doing and generate a new .mo each time I make a change, or what am I missing? Thank in advanced
The Result ========== ![enter image description here](https://i.stack.imgur.com/swJK1.png) ### Username You can declare the form field value global and prefill it. > > This will override any setting done via the "Remember me"-Checkbox. > > > ``` /** * Changes the default user name to "DEMO" * * @return st...
40,017
<p>Here's what I see when I click on the HTML tab in the editor...</p> <pre><code>&lt;div style="margin: 10px 0;"&gt;&lt;a href="test.jpg" rel="nofollow" target="_blank"&gt; &lt;img style="float: left; margin: 10px; max-width: 25%;" title="test" src="test.jpg" alt="test" /&gt; &lt;/a&gt;&lt;a href="test" rel="nofollow...
[ { "answer_id": 39995, "author": "Brooke.", "author_id": 2204, "author_profile": "https://wordpress.stackexchange.com/users/2204", "pm_score": 2, "selected": false, "text": "<p>Here are 3 ways to do it:</p>\n\n<p>The first way is to use the <a href=\"http://codex.wordpress.org/Function_Re...
2012/01/24
[ "https://wordpress.stackexchange.com/questions/40017", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6620/" ]
Here's what I see when I click on the HTML tab in the editor... ``` <div style="margin: 10px 0;"><a href="test.jpg" rel="nofollow" target="_blank"> <img style="float: left; margin: 10px; max-width: 25%;" title="test" src="test.jpg" alt="test" /> </a><a href="test" rel="nofollow" target="_blank"> <img title="PDF file" ...
The Result ========== ![enter image description here](https://i.stack.imgur.com/swJK1.png) ### Username You can declare the form field value global and prefill it. > > This will override any setting done via the "Remember me"-Checkbox. > > > ``` /** * Changes the default user name to "DEMO" * * @return st...
40,031
<p>I have a nav menu call:</p> 'primary', 'container_class' => 'primary-menu' ) ); ?> <p>The output looks something like this:</p> <pre><code>&lt;div class="primary-menu"&gt;&lt;ul id="menu-other-links" class="menu"&gt; &lt;li id="menu-item-51" class="menu-item menu-item-type-custom"&gt;&lt;a href="#"&gt;RSS&lt;/a&...
[ { "answer_id": 40035, "author": "Devin", "author_id": 12383, "author_profile": "https://wordpress.stackexchange.com/users/12383", "pm_score": 0, "selected": false, "text": "<p>check out <a href=\"http://codex.wordpress.org/Function_Reference/wp_nav_menu\" rel=\"nofollow\">http://codex.wo...
2012/01/24
[ "https://wordpress.stackexchange.com/questions/40031", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12290/" ]
I have a nav menu call: 'primary', 'container\_class' => 'primary-menu' ) ); ?> The output looks something like this: ``` <div class="primary-menu"><ul id="menu-other-links" class="menu"> <li id="menu-item-51" class="menu-item menu-item-type-custom"><a href="#">RSS</a></li> <li id="menu-item-49" class="menu-item me...
If you can stand to not have it be backwards compatible, CSS3 introduced the nth-child selector, you could leverage that
40,065
<p>I want to execute a function, myfunction() [hypothetically named], whenever a page is updated in the admin. The function doesn't do anything to the content that is saved—it just runs an unrelated task elsewhere. </p> <p>I read that the <code>post_updated</code> hook is good to use for this, but I cannot seem to ge...
[ { "answer_id": 40067, "author": "Jared", "author_id": 2415, "author_profile": "https://wordpress.stackexchange.com/users/2415", "pm_score": 2, "selected": false, "text": "<p>You should be able to get the ID of the post through the <code>$_POST</code> variable.</p>\n\n<p><strong>EDIT:</st...
2012/01/25
[ "https://wordpress.stackexchange.com/questions/40065", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3564/" ]
I want to execute a function, myfunction() [hypothetically named], whenever a page is updated in the admin. The function doesn't do anything to the content that is saved—it just runs an unrelated task elsewhere. I read that the `post_updated` hook is good to use for this, but I cannot seem to get this code to run: `...
You should be able to get the ID of the post through the `$_POST` variable. **EDIT:** Maybe you should try doing this on the `save_post` action, like so, but `save_post` sometimes runs on other instances (ie. Autosave Drafts), so you'll want to do some more verifying. `save_post` will also return the ID as one of the ...
40,068
<p>I have the following code. I am trying to enter data into the custom metabox and then save it. When I go to view it has entered a post, however the name column has nothing in it. Also when I hit save I get a post.php page with a blank page, is this a page I need to create in my theme and have it go back to the curre...
[ { "answer_id": 40075, "author": "Jared", "author_id": 2415, "author_profile": "https://wordpress.stackexchange.com/users/2415", "pm_score": 1, "selected": false, "text": "<p>The <code>save_post</code> action will return the ID of the post you're saving for you.</p>\n\n<p>You may also wan...
2012/01/25
[ "https://wordpress.stackexchange.com/questions/40068", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7653/" ]
I have the following code. I am trying to enter data into the custom metabox and then save it. When I go to view it has entered a post, however the name column has nothing in it. Also when I hit save I get a post.php page with a blank page, is this a page I need to create in my theme and have it go back to the current ...
You need to replace the field name from `name` to something else since `name` is a reserved word and could be whats causing the blank page, also its better practice to prefix you field names. Now in your save\_details\_booktime function make sure you are no the right post type and not in autosave, something like this:...
40,076
<p>Checking for front page with either is_home() or is_front_page() still removes the edit link from all pages/posts. What's wrong with this?</p> <pre><code>add_filter( 'edit_post_link', 'foo_edit_post_link' ); function foo_edit_post_link() { if (is_home()) { return FALSE; } } </code></pre>
[ { "answer_id": 40079, "author": "Brooke.", "author_id": 2204, "author_profile": "https://wordpress.stackexchange.com/users/2204", "pm_score": 0, "selected": false, "text": "<p>Assuming you're using a custom template why not just remove the_loop from your template?</p>\n" }, { "an...
2012/01/25
[ "https://wordpress.stackexchange.com/questions/40076", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5299/" ]
Checking for front page with either is\_home() or is\_front\_page() still removes the edit link from all pages/posts. What's wrong with this? ``` add_filter( 'edit_post_link', 'foo_edit_post_link' ); function foo_edit_post_link() { if (is_home()) { return FALSE; } } ```
Try ``` function foo_edit_post_link($link) { if (is_home()) { return FALSE; } return $link; } ```
40,082
<p>I had problem using admin-ajax.php while creating one plugin. I had problem using "add_action( 'wp_ajax_ajax_action', 'ajax_action_stuff' )" in my plugin where i have used oop module. So I want to go with jquery native way like below :</p> <pre><code>$.ajax({ url: "test.html", context: document.body, success...
[ { "answer_id": 40079, "author": "Brooke.", "author_id": 2204, "author_profile": "https://wordpress.stackexchange.com/users/2204", "pm_score": 0, "selected": false, "text": "<p>Assuming you're using a custom template why not just remove the_loop from your template?</p>\n" }, { "an...
2012/01/25
[ "https://wordpress.stackexchange.com/questions/40082", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11668/" ]
I had problem using admin-ajax.php while creating one plugin. I had problem using "add\_action( 'wp\_ajax\_ajax\_action', 'ajax\_action\_stuff' )" in my plugin where i have used oop module. So I want to go with jquery native way like below : ``` $.ajax({ url: "test.html", context: document.body, success: functi...
Try ``` function foo_edit_post_link($link) { if (is_home()) { return FALSE; } return $link; } ```
40,109
<p>I am not sure if this started with the latest upgrade (didn't notice it until yesterday), but the lists are no longer ordering by either asc or dsc. Doesn't matter which I chooose, or which list, they have all stopped ordering alphabetically. (I use orderby=title order=asc)</p>
[ { "answer_id": 40110, "author": "Sufiyan Ghori", "author_id": 12276, "author_profile": "https://wordpress.stackexchange.com/users/12276", "pm_score": 0, "selected": false, "text": "<p>you can use query_post in order to order the list according to your requirement,</p>\n\n<p>have a look,<...
2012/01/25
[ "https://wordpress.stackexchange.com/questions/40109", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10156/" ]
I am not sure if this started with the latest upgrade (didn't notice it until yesterday), but the lists are no longer ordering by either asc or dsc. Doesn't matter which I chooose, or which list, they have all stopped ordering alphabetically. (I use orderby=title order=asc)
While Xufyan's answer will get the job done, it does cause your page loads to run an extra query and you might get some unpredictable behavior. Furthermore, it doesn't get to the root of your issue. If you're comfortable with PHP, open up your theme's functions.php file and enter this: ``` add_filter('request', 'orde...
40,111
<p>In the attachments edit page i'm trying to use the selected thumbnail instead of the default icon. 99% of the way there but i can't get the attachment's id into the function.</p> <p>Am i missing something obvious? Help appreciated! Dc. </p> <pre><code>function set_attachments_icon($icon, $mime = null, $post_id){ ...
[ { "answer_id": 40113, "author": "Matthew Boynes", "author_id": 12324, "author_profile": "https://wordpress.stackexchange.com/users/12324", "pm_score": 0, "selected": false, "text": "<p>The apply_filters call is as follows:</p>\n\n<pre><code>apply_filters( 'wp_mime_type_icon', $icon, $mim...
2012/01/25
[ "https://wordpress.stackexchange.com/questions/40111", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3978/" ]
In the attachments edit page i'm trying to use the selected thumbnail instead of the default icon. 99% of the way there but i can't get the attachment's id into the function. Am i missing something obvious? Help appreciated! Dc. ``` function set_attachments_icon($icon, $mime = null, $post_id){ $vars = get_define...
First, you don't need the apply\_filters below. That is called directly from the wp\_mime\_type\_icon() function already. The issue is that your add\_filter() call is missing the $accepted\_args parameter. The add\_filter() function has the following construct: ``` add_filter($tag, $function_to_add, $priority = 10, $...
40,128
<p>I have been in the process of adding the link post format to the thematic theme via a <a href="https://github.com/MikeWills/MikeWillsThematic" rel="nofollow">child theme</a>. To be honest, this is the first time I have done any sort of theme work with WordPress.</p> <p>I have been able to change the title permalink...
[ { "answer_id": 40206, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 1, "selected": false, "text": "<p>as a self-appointed thematic support guru, i can simplify your first filter:</p>\n\n<pre><code>/**\n * Ov...
2012/01/25
[ "https://wordpress.stackexchange.com/questions/40128", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104/" ]
I have been in the process of adding the link post format to the thematic theme via a [child theme](https://github.com/MikeWills/MikeWillsThematic). To be honest, this is the first time I have done any sort of theme work with WordPress. I have been able to change the title permalink to the link I am linking to and add...
I figured out the right search terms and found out [how to add content to the RSS feed](http://www.wpbeginner.com/wp-tutorials/how-to-add-content-and-completely-manipulate-your-wordpress-rss-feeds/). ``` // Add permalink to RSS feed function mikewillsthematic_postrss($content) { if(is_feed() && has_post_format('li...
40,129
<p>I'm building a custom plugin for a Wordpress project I'm building as it's quite a specific project, and there isn't an off the shelf plugin suitable for the task.</p> <p>On one page I want to list objects from the database (which is also a custom database table) in a table. There is currently one item in the databa...
[ { "answer_id": 40131, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": false, "text": "<p>Your problem is probably here:</p>\n\n<pre><code>foreach($satrent as $sr)\n</code></pre>\n\n<p>...and here:...
2012/01/25
[ "https://wordpress.stackexchange.com/questions/40129", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12267/" ]
I'm building a custom plugin for a Wordpress project I'm building as it's quite a specific project, and there isn't an off the shelf plugin suitable for the task. On one page I want to list objects from the database (which is also a custom database table) in a table. There is currently one item in the database, and I ...
The problem is that `get_row` returns a row object (or array), not an array of row objects. You want `$wpdb->get_results` instead. This always returns an array of row objects, event if there is only one result. You may also wish to add an ``` if($satrent){ //Foreach on $satrent } ``` so that if no resul...
40,135
<p>I've been reading <a href="https://wordpress.stackexchange.com/questions/4664/what-are-best-practices-for-configuring-a-server-for-wordpress-sites">some</a> <a href="https://wordpress.stackexchange.com/questions/36847/how-to-configure-self-hosted-wordpress-so-that-everything-can-be-upgraded-instal">posts</a> that se...
[ { "answer_id": 40131, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": false, "text": "<p>Your problem is probably here:</p>\n\n<pre><code>foreach($satrent as $sr)\n</code></pre>\n\n<p>...and here:...
2012/01/25
[ "https://wordpress.stackexchange.com/questions/40135", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3687/" ]
I've been reading [some](https://wordpress.stackexchange.com/questions/4664/what-are-best-practices-for-configuring-a-server-for-wordpress-sites) [posts](https://wordpress.stackexchange.com/questions/36847/how-to-configure-self-hosted-wordpress-so-that-everything-can-be-upgraded-instal) that seem to touch on this (or p...
The problem is that `get_row` returns a row object (or array), not an array of row objects. You want `$wpdb->get_results` instead. This always returns an array of row objects, event if there is only one result. You may also wish to add an ``` if($satrent){ //Foreach on $satrent } ``` so that if no resul...
40,140
<p>I'm working on a project with WP, a bit like a plugin, but not quite one.</p> <p>I'm encountering an issue, when trying to include a file that contains some custom SQL functions in a class, in a completely different file, I get redirected to <code>http://example.com/folder1/file.php/wp-admin/install.php</code></p> ...
[ { "answer_id": 40131, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": false, "text": "<p>Your problem is probably here:</p>\n\n<pre><code>foreach($satrent as $sr)\n</code></pre>\n\n<p>...and here:...
2012/01/25
[ "https://wordpress.stackexchange.com/questions/40140", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I'm working on a project with WP, a bit like a plugin, but not quite one. I'm encountering an issue, when trying to include a file that contains some custom SQL functions in a class, in a completely different file, I get redirected to `http://example.com/folder1/file.php/wp-admin/install.php` Which states that I've a...
The problem is that `get_row` returns a row object (or array), not an array of row objects. You want `$wpdb->get_results` instead. This always returns an array of row objects, event if there is only one result. You may also wish to add an ``` if($satrent){ //Foreach on $satrent } ``` so that if no resul...
40,149
<p>Something is wrong with my wp-admin page, it just shows up blank. I am pretty sure it has to do with my function.php file there is no whitespace on the top or bottom, but when I delete it completely, the wp-admin folder works again. </p> <p>here is the functions.php file</p> <pre><code>&lt;?php add_action("manage...
[ { "answer_id": 40151, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": false, "text": "<p>You need to remove spaces between <em>all</em> closing/opening PHP tags, including:</p>\n\n<pre><code>}\n?&...
2012/01/25
[ "https://wordpress.stackexchange.com/questions/40149", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7653/" ]
Something is wrong with my wp-admin page, it just shows up blank. I am pretty sure it has to do with my function.php file there is no whitespace on the top or bottom, but when I delete it completely, the wp-admin folder works again. here is the functions.php file ``` <?php add_action("manage_posts_custom_column", ...
I turned wp-config debug on, and found the bug. This piece of code was in there at line 61 for some reason and it was causing the error. `<p><label>Name:</label><br /> <input type="text" name="name" value="<?php echo $name; ?>"/></p>`
40,153
<p>I've setup a very specific function and it works well but I'd like to make the parameters optional but I can't get a handle on the regex bit:</p> <pre><code>add_rewrite_rule('whats-on/([^/]+)/([^/]+)/([^/]+)/?$', 'index.php?page_id=71&amp;event_year=$matches[1]&amp;event_month=$matches[2]&amp;event_day=$matches[3]'...
[ { "answer_id": 40165, "author": "2hamed", "author_id": 7410, "author_profile": "https://wordpress.stackexchange.com/users/7410", "pm_score": 0, "selected": false, "text": "<p>The following would be the correct regex:</p>\n\n<pre><code>add_rewrite_rule('whats-on/([^/]+)/([^/]*)/([^/]*)/?$...
2012/01/25
[ "https://wordpress.stackexchange.com/questions/40153", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12450/" ]
I've setup a very specific function and it works well but I'd like to make the parameters optional but I can't get a handle on the regex bit: ``` add_rewrite_rule('whats-on/([^/]+)/([^/]+)/([^/]+)/?$', 'index.php?page_id=71&event_year=$matches[1]&event_month=$matches[2]&event_day=$matches[3]','top'); ``` `/whats-on/...
Two points: 1. Your rule isn't particularly specific. For numeric matches you should be specific about it and specify a) digits and b) how many digits. Year would be `([0-9]{4})`, month/day would be `([0-9]{1,2})`. 2. You can't do it with one rule. Add three separate rules instead. ``` add_rewrite_rule( 'whats-on/([0...
40,161
<p>I know the page template is set in the wpdb as meta_key = _wp_page_template and meta_value = template.php.</p> <p>How can I write a SQL script to set each post where post_type = 'page' to a specific template?</p> <p><strong>EDIT:</strong> Based on the comments below, I'll add the detail that I am wishing to "norma...
[ { "answer_id": 40168, "author": "Jared", "author_id": 2415, "author_profile": "https://wordpress.stackexchange.com/users/2415", "pm_score": 3, "selected": true, "text": "<p><strong>EDIT</strong> As noted in the comments on your question, the best approach would just be to edit your <code...
2012/01/25
[ "https://wordpress.stackexchange.com/questions/40161", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10099/" ]
I know the page template is set in the wpdb as meta\_key = \_wp\_page\_template and meta\_value = template.php. How can I write a SQL script to set each post where post\_type = 'page' to a specific template? **EDIT:** Based on the comments below, I'll add the detail that I am wishing to "normalize" my pages since som...
**EDIT** As noted in the comments on your question, the best approach would just be to edit your `page.php` file. If you want ALL of your pages to have the same page template, and not have to do anything extra to set it that way, it's quite obvious why this is a good idea. :) Then, you can make a custom page template ...
40,174
<p>I am using the theme <code>twentyten</code> as a parent theme for my child theme. I have other stylesheets I want to use and so I'm trying to figure out how to <code>wp_deregister_style</code> for the <code>style.css</code> sheet that is printed out in the <code>head</code> section of the html.</p> <p>I have checke...
[ { "answer_id": 40175, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 0, "selected": false, "text": "<p>Why don't you replace the contents of the <code>style.css</code> in your child theme with the contents of...
2012/01/25
[ "https://wordpress.stackexchange.com/questions/40174", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4400/" ]
I am using the theme `twentyten` as a parent theme for my child theme. I have other stylesheets I want to use and so I'm trying to figure out how to `wp_deregister_style` for the `style.css` sheet that is printed out in the `head` section of the html. I have checked the global `$wp_styles` variable around the `shutdow...
Twentyten has a `header.php` file which has the style.css hardcoded into it: ``` <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" /> ``` There is no way to `wp_dequeue_style` because it is never "loaded" with `wp_enqueue_style` in the first place. To get that out of t...
40,176
<p>We do a lot of post maintenance outside of the WordPress interface and as a result we need ways of categorising posts. Obviously Wordpress has categories (aka taxonomies) on posts and I plan on using them, but haven't found a way that I can do that in code. </p> <p>We also use custom post types extensively so the a...
[ { "answer_id": 40177, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 1, "selected": false, "text": "<p>You should be able to do just about everything you're looking to do between <a href=\"http://codex.wordpress....
2012/01/25
[ "https://wordpress.stackexchange.com/questions/40176", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9519/" ]
We do a lot of post maintenance outside of the WordPress interface and as a result we need ways of categorising posts. Obviously Wordpress has categories (aka taxonomies) on posts and I plan on using them, but haven't found a way that I can do that in code. We also use custom post types extensively so the accepted an...
There's the `wp_update_post()`, also. According to categories, please refer to the [documentation](http://codex.wordpress.org/Function_Reference/wp_update_post). > > Categories need to be passed as an array of integers that match the > category IDs in the database. This is the case even where only one > category i...
40,192
<p>I created a meta box with a value "home" of type checkbox, however I'm having hard times retrieving into the loop, I'm using this code into the loop:</p> <pre><code> &lt;?php if(get_post_meta(get_the_ID(), 'home') == '1' ) : ?&gt; &lt;!--BLABLA TO DISPLAY --&gt; &lt;?php endif; ?&gt; </code></pre> <p>if the che...
[ { "answer_id": 40193, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 1, "selected": false, "text": "<p>You need to add the third parameter to <code>get_post_meta()</code>, so <code>get_post_meta( get_the_ID(), 'h...
2012/01/25
[ "https://wordpress.stackexchange.com/questions/40192", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4907/" ]
I created a meta box with a value "home" of type checkbox, however I'm having hard times retrieving into the loop, I'm using this code into the loop: ``` <?php if(get_post_meta(get_the_ID(), 'home') == '1' ) : ?> <!--BLABLA TO DISPLAY --> <?php endif; ?> ``` if the checkbox is checked it should work like this, h...
After some research I was able to solve it... looks like it understands the values as 'on' and 'off'... with this validation it works like charm ``` <?php if(get_post_meta(get_the_ID(), 'home', true) == 'on') : ?> <?php the_title() ?> <?php endif; ?> ```
40,200
<p>I've got an "Event" custom post type. Each post has a meta field for the actual event date, which cannot be the posts's publish date, as most all the event dates will be in the future.</p> <p>With that, I'm trying to create an archive (year and month) for past and future events based on the meta field. Just can't w...
[ { "answer_id": 40202, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 0, "selected": false, "text": "<p>Your URL display won't work like that unfortunately...not without a good amount of shoehorning at least.</p>\...
2012/01/26
[ "https://wordpress.stackexchange.com/questions/40200", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11516/" ]
I've got an "Event" custom post type. Each post has a meta field for the actual event date, which cannot be the posts's publish date, as most all the event dates will be in the future. With that, I'm trying to create an archive (year and month) for past and future events based on the meta field. Just can't wrap my hea...
I did something similar for a client a while back, I'll give you some of the code here as-is that you can possibly adapt to your needs. I'll warn you, it's quite a bit to parse through! First, I set up some custom rewrite rules to get the year/month URL structure and some query vars to pass the year and month to my te...
40,226
<p>I need to add something after each title of a specific menu called by wp_nav_menu()</p> <p>I tried </p> <pre><code>add_filter('wp_nav_title', 'testing_stuff'); </code></pre> <p>with </p> <pre><code>function testing_stuff() { $item-&gt;title = $item-&gt;title . ' testing'; return $item-&gt;title; </code></pre> <...
[ { "answer_id": 40238, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 3, "selected": true, "text": "<p>The following works, but with the following caveats. It will <strong>run for every menu</strong>, but it w...
2012/01/26
[ "https://wordpress.stackexchange.com/questions/40226", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9458/" ]
I need to add something after each title of a specific menu called by wp\_nav\_menu() I tried ``` add_filter('wp_nav_title', 'testing_stuff'); ``` with ``` function testing_stuff() { $item->title = $item->title . ' testing'; return $item->title; ``` } without any success, i'm not familiar enough with hooking....
The following works, but with the following caveats. It will **run for every menu**, but it will **not run for `wp_page_menu`**, a usuall default callback if a menu can't be found. Finally, menu items aren't necessary pages - so you may want to do some logic to check that the menu item you are dealing with is a page/p...
40,227
<p>I have a winery website with the custom post type "wine", each wine has various custom meta fields like "vintage", "pH", "Varietal-Composition" etc...</p> <p>Now, i would like to list all wines where vintage=2005.</p> <p>Any pointers?</p>
[ { "answer_id": 40230, "author": "Simon", "author_id": 9458, "author_profile": "https://wordpress.stackexchange.com/users/9458", "pm_score": 1, "selected": false, "text": "<p>Check this : <a href=\"https://wordpress.stackexchange.com/questions/37402/get-posts-by-meta-data-or-title\">Get p...
2012/01/26
[ "https://wordpress.stackexchange.com/questions/40227", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10302/" ]
I have a winery website with the custom post type "wine", each wine has various custom meta fields like "vintage", "pH", "Varietal-Composition" etc... Now, i would like to list all wines where vintage=2005. Any pointers?
Check this : [Get posts by meta data OR title](https://wordpress.stackexchange.com/questions/37402/get-posts-by-meta-data-or-title) The first piece of code is working and allow to make a query based on meta data You could just get rid of useless stuff (or adapt if you want to use several keys) : ``` $args = array( ...
40,245
<p>I have added an image size using this:</p> <pre><code>add_image_size('property-featured', 484, 393, true); </code></pre> <p>It's worked very well for the past year and has generated about 1GB of images in that size, but this image size is no longer needed. I want to clear up the images that have been created over ...
[ { "answer_id": 40248, "author": "Scott", "author_id": 4610, "author_profile": "https://wordpress.stackexchange.com/users/4610", "pm_score": 4, "selected": true, "text": "<p>I found a plugin that does this for me: <a href=\"http://wordpress.org/extend/plugins/additional-image-sizes-zui/\"...
2012/01/26
[ "https://wordpress.stackexchange.com/questions/40245", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4610/" ]
I have added an image size using this: ``` add_image_size('property-featured', 484, 393, true); ``` It's worked very well for the past year and has generated about 1GB of images in that size, but this image size is no longer needed. I want to clear up the images that have been created over the year in this size. So...
I found a plugin that does this for me: [Additional image sizes (zui)](http://wordpress.org/extend/plugins/additional-image-sizes-zui/) > > When you delete an image size that size will not be created for all NEW images you upload. > However, images created for deleted sizes still exist on the server as well as the ...
40,256
<p>Is there a function or a hook that runs only when a theme is previewed? </p> <p>I'm referring to the preview feature that you get on the Appearance->Themes page.</p> <p>The reason for this is that I want to <strong>change specific design aspects on the theme but only when the user is previewing it</strong>.</p>
[ { "answer_id": 40248, "author": "Scott", "author_id": 4610, "author_profile": "https://wordpress.stackexchange.com/users/4610", "pm_score": 4, "selected": true, "text": "<p>I found a plugin that does this for me: <a href=\"http://wordpress.org/extend/plugins/additional-image-sizes-zui/\"...
2012/01/26
[ "https://wordpress.stackexchange.com/questions/40256", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10531/" ]
Is there a function or a hook that runs only when a theme is previewed? I'm referring to the preview feature that you get on the Appearance->Themes page. The reason for this is that I want to **change specific design aspects on the theme but only when the user is previewing it**.
I found a plugin that does this for me: [Additional image sizes (zui)](http://wordpress.org/extend/plugins/additional-image-sizes-zui/) > > When you delete an image size that size will not be created for all NEW images you upload. > However, images created for deleted sizes still exist on the server as well as the ...
40,278
<p>How do I create a registration template in Buddypress? I can't seem to find any way to integrate the registration form in a template page. I tried adding this code to my template page, it displays nothing but a blank form:</p> <p><a href="http://pastebin.com/QsL65A53" rel="nofollow">http://pastebin.com/QsL65A53</a>...
[ { "answer_id": 40288, "author": "Joseph Leedy", "author_id": 8554, "author_profile": "https://wordpress.stackexchange.com/users/8554", "pm_score": 0, "selected": false, "text": "<p>Install the <a href=\"http://wordpress.org/extend/plugins/bp-template-pack/\" rel=\"nofollow\">BP Template ...
2012/01/26
[ "https://wordpress.stackexchange.com/questions/40278", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1905/" ]
How do I create a registration template in Buddypress? I can't seem to find any way to integrate the registration form in a template page. I tried adding this code to my template page, it displays nothing but a blank form: <http://pastebin.com/QsL65A53> Can anyone tell me what I am doing wrong? **UPDATE:** --- Now...
Try putting this snippit below the get\_header section: ``` <?php global $bp; if(empty($bp->signup->step)) $bp->signup->step='request-details'; ?> ```
40,290
<p>I am about to change the slug for my page's permalink. Since I dont want to loose the traffic, i would like to redirect the visitors to the new more SEo friendly link.</p> <p>Can I achieve this with the mod_rewrite? (I use Apache on Ubuntu)</p> <p>Or any other easier alternative? (I prefer not using any plugin if ...
[ { "answer_id": 40288, "author": "Joseph Leedy", "author_id": 8554, "author_profile": "https://wordpress.stackexchange.com/users/8554", "pm_score": 0, "selected": false, "text": "<p>Install the <a href=\"http://wordpress.org/extend/plugins/bp-template-pack/\" rel=\"nofollow\">BP Template ...
2012/01/26
[ "https://wordpress.stackexchange.com/questions/40290", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9024/" ]
I am about to change the slug for my page's permalink. Since I dont want to loose the traffic, i would like to redirect the visitors to the new more SEo friendly link. Can I achieve this with the mod\_rewrite? (I use Apache on Ubuntu) Or any other easier alternative? (I prefer not using any plugin if possible) Many ...
Try putting this snippit below the get\_header section: ``` <?php global $bp; if(empty($bp->signup->step)) $bp->signup->step='request-details'; ?> ```
40,292
<pre><code>class checkPost{ function __construct() { if ( !wp_next_scheduled('my_task_hook') ) { wp_schedule_event( time(), 'hourly', 'my_task_hook' ); // hourly, daily and twicedaily } add_action('my_task_hook', array(&amp;$this,'my_task_function')); } function my_task_function() { add...
[ { "answer_id": 40294, "author": "Rob Vermeer", "author_id": 11135, "author_profile": "https://wordpress.stackexchange.com/users/11135", "pm_score": 0, "selected": false, "text": "<p>I think it is working. I pasted your code in my functions.php and called the class. Then with a <a href=\"...
2012/01/26
[ "https://wordpress.stackexchange.com/questions/40292", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8711/" ]
``` class checkPost{ function __construct() { if ( !wp_next_scheduled('my_task_hook') ) { wp_schedule_event( time(), 'hourly', 'my_task_hook' ); // hourly, daily and twicedaily } add_action('my_task_hook', array(&$this,'my_task_function')); } function my_task_function() { add_action('wp...
You can't add an action to wp\_head inside a wp-cron job. The wp-cron tasks run outside of the normal flow, so while you can add your action, it won't actually do anything to anybody viewing the page. Cron jobs are called via separate http requests, no user normally will see their results. In other words, your code wo...
40,301
<p>While looking through the <a href="http://codex.wordpress.org/Function_Reference/wp_insert_post">function reference entry for wp_insert_post()</a>, I noticed that there's no parameter in the array it requires which will allow me to set the 'Featured Image' for a post, displayed as the <a href="http://codex.wordpress...
[ { "answer_id": 40302, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 3, "selected": false, "text": "<p>Try using <a href=\"http://codex.wordpress.org/Function_Reference/set_post_thumbnail\"><code>set_post_thumb...
2012/01/26
[ "https://wordpress.stackexchange.com/questions/40301", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12310/" ]
While looking through the [function reference entry for wp\_insert\_post()](http://codex.wordpress.org/Function_Reference/wp_insert_post), I noticed that there's no parameter in the array it requires which will allow me to set the 'Featured Image' for a post, displayed as the [post thumbnail](http://codex.wordpress.org...
You can set an image as post thumbnail when it is in your media library. To add an image in your media library you need to upload it to your server. WordPress already has a function for putting images in your media library, you only need a script that uploads your file. Usage: ``` Generate_Featured_Image( '../wp-cont...
40,304
<p>I don't want to write out something like this from 1 to 1000:</p> <pre><code> &lt;select name="number_pick" id="number_pick" &gt; &lt;option value="1" &lt;?php selected( '1', get_the_author_meta( 'number', $user-&gt;ID ) ); ?&gt;&gt;1&lt;/option&gt; &lt;option value="2" &lt;?php selected(...
[ { "answer_id": 40305, "author": "Rob Vermeer", "author_id": 11135, "author_profile": "https://wordpress.stackexchange.com/users/11135", "pm_score": 1, "selected": false, "text": "<p>Fist off, why a dropdown of 1000 items? Why not using a textinput field and check if the input is between ...
2012/01/26
[ "https://wordpress.stackexchange.com/questions/40304", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2107/" ]
I don't want to write out something like this from 1 to 1000: ``` <select name="number_pick" id="number_pick" > <option value="1" <?php selected( '1', get_the_author_meta( 'number', $user->ID ) ); ?>>1</option> <option value="2" <?php selected( '2', get_the_author_meta( 'number', $user->ID ...
you can save the 1000 conditional checks by using `str_replace` and your code would be much more efficient, something like this: ``` //create the select options $options =''; for($i=1;$i<=1000;$i++) { $options.= '<option value="'.$i.'">'.$i.'</option>'; } //get the saved data $saved = get_the_author_meta( 'numbe...
40,309
<p>How can I get the post_type while on the post.php page?</p> <p>I'm working on a plugin that lets users create a new post type. Then in the new post type, a meta box will be added with some options. The meta box to be added is based on certain parameters that were set while creating the new post type. </p> <p>So I ...
[ { "answer_id": 40311, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": false, "text": "<p>Why can't you just globalize <code>$post</code> and then get the post type? e.g.</p>\n\n<pre><code>&lt;?php...
2012/01/26
[ "https://wordpress.stackexchange.com/questions/40309", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12484/" ]
How can I get the post\_type while on the post.php page? I'm working on a plugin that lets users create a new post type. Then in the new post type, a meta box will be added with some options. The meta box to be added is based on certain parameters that were set while creating the new post type. So I need to check wh...
Why can't you just globalize `$post` and then get the post type? e.g. ``` <?php global $post; $post_type = get_post_type( $post->ID ); ?> ``` In what context are you placing this code? In a metabox callback, or what? (Also: why are you using `$_GET` data?)
40,319
<p>I'm trying to come up with a solution that would allow me to remove the default post types (pages, posts, comments, links, etc) from all the multi-site blogs EXECEPT the primary blog. It will remain fully functional. My purpose is to apply a custom post type to all the multi-site blogs to replace the defaults.</p>...
[ { "answer_id": 40311, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": false, "text": "<p>Why can't you just globalize <code>$post</code> and then get the post type? e.g.</p>\n\n<pre><code>&lt;?php...
2012/01/27
[ "https://wordpress.stackexchange.com/questions/40319", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11880/" ]
I'm trying to come up with a solution that would allow me to remove the default post types (pages, posts, comments, links, etc) from all the multi-site blogs EXECEPT the primary blog. It will remain fully functional. My purpose is to apply a custom post type to all the multi-site blogs to replace the defaults. Any hel...
Why can't you just globalize `$post` and then get the post type? e.g. ``` <?php global $post; $post_type = get_post_type( $post->ID ); ?> ``` In what context are you placing this code? In a metabox callback, or what? (Also: why are you using `$_GET` data?)
40,321
<p>Im looking for a way to make tags a searchable object. To clarify, Im NOT trying to make the search engine search posts by looking at its tags, but I want tags to show up in the results just like a post. any help would be much apreciated</p>
[ { "answer_id": 40311, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": false, "text": "<p>Why can't you just globalize <code>$post</code> and then get the post type? e.g.</p>\n\n<pre><code>&lt;?php...
2012/01/27
[ "https://wordpress.stackexchange.com/questions/40321", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8518/" ]
Im looking for a way to make tags a searchable object. To clarify, Im NOT trying to make the search engine search posts by looking at its tags, but I want tags to show up in the results just like a post. any help would be much apreciated
Why can't you just globalize `$post` and then get the post type? e.g. ``` <?php global $post; $post_type = get_post_type( $post->ID ); ?> ``` In what context are you placing this code? In a metabox callback, or what? (Also: why are you using `$_GET` data?)
40,322
<p>How to query for mutiple meta key values with the same key </p> <pre><code>$querystr = " SELECT $wpdb-&gt;posts.* FROM $wpdb-&gt;posts, $wpdb-&gt;postmeta WHERE $wpdb-&gt;posts.ID = $wpdb-&gt;postmeta.post_id AND $wpdb-&gt;postmeta.meta_key = 'key1' ...
[ { "answer_id": 40324, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 1, "selected": false, "text": "<p>You have to alias the postmeta table for the second value:</p>\n<pre><code>$querystr = &quot; \n SELECT $wp...
2012/01/27
[ "https://wordpress.stackexchange.com/questions/40322", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10705/" ]
How to query for mutiple meta key values with the same key ``` $querystr = " SELECT $wpdb->posts.* FROM $wpdb->posts, $wpdb->postmeta WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = 'key1' AND $wpdb->postmeta.meta_value...
I feel like there's an AND/OR confusion going on here. The queries in the OP will only return posts which have *both* key1 = 'value1' AND key2 = 'value2'. Most WP plugins (that I know of, anyway) do not store multiple values in postmeta, for the same post, using the same key. If what you want is really an OR (you wan...
40,338
<p>I want to create one extra table filed if it is multisite's main blog (While plugin activation). </p> <p>I mean like this </p> <pre><code>if (main blog) { execute this sql; } else { execute this sql } </code></pre> <p>PS: This is the code for "execute this sql".</p> <h2>If child blog:</h2> <pre><code>$sql =...
[ { "answer_id": 40369, "author": "5t3ph", "author_id": 6161, "author_profile": "https://wordpress.stackexchange.com/users/6161", "pm_score": 2, "selected": false, "text": "<p>Check for the $blogid. Main site is 1.</p>\n\n<pre><code>global $wpdb;\n\n$mainblog = $wpdb-&gt;blogid;\n\nif ($ma...
2012/01/27
[ "https://wordpress.stackexchange.com/questions/40338", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5074/" ]
I want to create one extra table filed if it is multisite's main blog (While plugin activation). I mean like this ``` if (main blog) { execute this sql; } else { execute this sql } ``` PS: This is the code for "execute this sql". If child blog: -------------- ``` $sql = "CREATE TABLE tablename ( ...
You can use [is\_main\_site](http://codex.wordpress.org/Function_Reference/is_main_site) conditional tag like this: ``` if (is_main_site()) { execute this sql; } else { execute this sql } ```
40,341
<p>I found <a href="http://voodoopress.com/review-of-posting-from-front-end-form/" rel="nofollow">this</a> tutorial to create a front end post submission form:</p> <p>It doesn't matter what I type on <code>wp_redirect( 'http://www.google.com' );</code> I don't get redirected to anywhere. Just the same page but withou...
[ { "answer_id": 40349, "author": "Rob Vermeer", "author_id": 11135, "author_profile": "https://wordpress.stackexchange.com/users/11135", "pm_score": 0, "selected": false, "text": "<p>This looks very much like this post: <a href=\"https://wordpress.stackexchange.com/questions/40236/not-red...
2012/01/27
[ "https://wordpress.stackexchange.com/questions/40341", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/781/" ]
I found [this](http://voodoopress.com/review-of-posting-from-front-end-form/) tutorial to create a front end post submission form: It doesn't matter what I type on `wp_redirect( 'http://www.google.com' );` I don't get redirected to anywhere. Just the same page but without the form (http://localhost/my-wordpress-site/...
Your code is not in the right order and you need to `exit` the script after using `wp_redirect` try this: ``` <?php /* Template Name: Rate Wine Form */ ?> <?php if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == "new_post") { // Do some minor form validation to ma...
40,364
<p>I have a Page on my site that I use as a Blog.</p> <p>And then there's another page that I'd like to add a few different posts to. It's not really a blog, it's a list of projects, and each one will have about 300 words of description.</p> <p>I'd like users to be able to pick which project they want to view. So thi...
[ { "answer_id": 40349, "author": "Rob Vermeer", "author_id": 11135, "author_profile": "https://wordpress.stackexchange.com/users/11135", "pm_score": 0, "selected": false, "text": "<p>This looks very much like this post: <a href=\"https://wordpress.stackexchange.com/questions/40236/not-red...
2012/01/27
[ "https://wordpress.stackexchange.com/questions/40364", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7692/" ]
I have a Page on my site that I use as a Blog. And then there's another page that I'd like to add a few different posts to. It's not really a blog, it's a list of projects, and each one will have about 300 words of description. I'd like users to be able to pick which project they want to view. So this could work as e...
Your code is not in the right order and you need to `exit` the script after using `wp_redirect` try this: ``` <?php /* Template Name: Rate Wine Form */ ?> <?php if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == "new_post") { // Do some minor form validation to ma...
40,401
<p>On post edit pages, when a slug exceeds a certain number of characters, Wordpress abridges it with an ellipsis (<code>...</code>). For example, if my slug is <code>i-want-to-be-able-to-see-this-slug</code>, it appears on the edit page like this:</p> <blockquote> <p><strong>Permalink:</strong> <code>http://example...
[ { "answer_id": 40405, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 2, "selected": false, "text": "<p>It's not possible via filter or action hook. WordPress cut the strings hard in core. See <code>wp-admin/includes/p...
2012/01/27
[ "https://wordpress.stackexchange.com/questions/40401", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3564/" ]
On post edit pages, when a slug exceeds a certain number of characters, Wordpress abridges it with an ellipsis (`...`). For example, if my slug is `i-want-to-be-able-to-see-this-slug`, it appears on the edit page like this: > > **Permalink:** `http://example.com/2012/i-want-to-be-a...-see-this-slug/` [ Edit ] > > >...
There is a filter at the end of the function: `'get_sample_permalink_html'`. Hook into this and just replace the shortened form with the full length. ``` <?php # -*- coding: utf-8 -*- /* Plugin Name: T5 Unabridge Permalink Slug */ add_filter( 'get_sample_permalink_html', 't5_unabridge_sample_permalink', 10, 2 ); /**...
40,408
<p><a href="http://2barnamenevis.com/" rel="nofollow">This</a> is my website. I installed many plugins but if a plugin have ajax, then it doesn't work in main page. can anybody help me?!?</p>
[ { "answer_id": 40405, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 2, "selected": false, "text": "<p>It's not possible via filter or action hook. WordPress cut the strings hard in core. See <code>wp-admin/includes/p...
2012/01/27
[ "https://wordpress.stackexchange.com/questions/40408", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10968/" ]
[This](http://2barnamenevis.com/) is my website. I installed many plugins but if a plugin have ajax, then it doesn't work in main page. can anybody help me?!?
There is a filter at the end of the function: `'get_sample_permalink_html'`. Hook into this and just replace the shortened form with the full length. ``` <?php # -*- coding: utf-8 -*- /* Plugin Name: T5 Unabridge Permalink Slug */ add_filter( 'get_sample_permalink_html', 't5_unabridge_sample_permalink', 10, 2 ); /**...
40,496
<p>I want to add a new post type </p> <p>i have a php file (posttype.php) at : wordpress/wp-content/themes/</p> <p>this is the code : </p> <pre><code>&lt;?php // Add new post type for Recipes add_action('init', 'cooking_recipes_init'); function cooking_recipes_init() { $args = array( 'label' =&gt; _x('R...
[ { "answer_id": 40479, "author": "Matthew Boynes", "author_id": 12324, "author_profile": "https://wordpress.stackexchange.com/users/12324", "pm_score": 2, "selected": false, "text": "<p>The \"user\" running your webserver (sometimes _www, sometimes www-data, sometimes \"nobody\") lacks th...
2012/01/28
[ "https://wordpress.stackexchange.com/questions/40496", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12546/" ]
I want to add a new post type i have a php file (posttype.php) at : wordpress/wp-content/themes/ this is the code : ``` <?php // Add new post type for Recipes add_action('init', 'cooking_recipes_init'); function cooking_recipes_init() { $args = array( 'label' => _x('Recipes'), 'singular_label'...
The "user" running your webserver (sometimes \_www, sometimes www-data, sometimes "nobody") lacks the permissions to edit these files. You can either change them to be owned by that user or change them to 777. To find out what your web server user is, assuming you're running apache, run `ps aux | grep httpd` in the com...
40,506
<p>In my buddypress I have set the register page as homepage. Now whenever a logged-in user tries to access the register page(homepage), they are redirected to Members directory. I want it to change to, home page. is there any way? I have tried changing the buddypress/bp-members/bp-members-signup.php file this way:</p>...
[ { "answer_id": 40515, "author": "Aces", "author_id": 7401, "author_profile": "https://wordpress.stackexchange.com/users/7401", "pm_score": 0, "selected": false, "text": "<p>Couldn't you use something like the walled garden technique. I'm not sure if it's quite what you want, but it is cu...
2012/01/28
[ "https://wordpress.stackexchange.com/questions/40506", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1905/" ]
In my buddypress I have set the register page as homepage. Now whenever a logged-in user tries to access the register page(homepage), they are redirected to Members directory. I want it to change to, home page. is there any way? I have tried changing the buddypress/bp-members/bp-members-signup.php file this way: ``` /...
Just a heads-up that you should be using the `bp_loggedin_register_page_redirect_to` filter to accomplish this, rather than modifying BuddyPress files (which will get overwritten on every upgrade). ``` function bbg_bp_loggedin_register_page_redirect_to( $redirect_to ) { if ( bp_is_component_front_page( 'register' ...
40,526
<p>I'm trying to get all users assigned to a custom usermeta. I know that <code>get_users()</code> is supposed to work; however, it doesn't seem to be working. What I have is a usermeta storing a category ID and I'm trying to use <code>'meta_value' =&gt; $cat_id</code> to query the database. So this is the code I have:...
[ { "answer_id": 40557, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<p>You could try to user a \"direct\" <a href=\"http://codex.wordpress.org/Class_Reference/WP_User_Query\" rel=\"nofol...
2012/01/29
[ "https://wordpress.stackexchange.com/questions/40526", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12543/" ]
I'm trying to get all users assigned to a custom usermeta. I know that `get_users()` is supposed to work; however, it doesn't seem to be working. What I have is a usermeta storing a category ID and I'm trying to use `'meta_value' => $cat_id` to query the database. So this is the code I have: ``` $args = array( 'me...
In your original code, you're not passing an operator to `meta_compare`. Note that [`get_users()`](http://codex.wordpress.org/Function_Reference/get_users) does *not* define a default operator. Try using `'='`: ``` $args = array( 'meta_key' => 'custom-usermeta', 'meta_value' => $cat_id, 'meta_compare' => '...
40,532
<p>I have a client with a very image heavy blog. Every time they upload images in their posts they are using the Attachment Post URL for the link instead of the File URL. The problem with this is that there is an image plugin that automatically zooms images nicely if they are links to the file but won't work if it's ...
[ { "answer_id": 40535, "author": "Daniel Nguyen", "author_id": 5691, "author_profile": "https://wordpress.stackexchange.com/users/5691", "pm_score": 2, "selected": false, "text": "<p>Create an attachment template file within the theme. Since we are only interested in images, the file shou...
2012/01/29
[ "https://wordpress.stackexchange.com/questions/40532", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12558/" ]
I have a client with a very image heavy blog. Every time they upload images in their posts they are using the Attachment Post URL for the link instead of the File URL. The problem with this is that there is an image plugin that automatically zooms images nicely if they are links to the file but won't work if it's a lin...
Create an attachment template file within the theme. Since we are only interested in images, the file should be **image.php** ``` <?php if ( have_posts() ) { the_post(); $image_url = wp_get_attachment_url(); } header('Location: '.$image_url); ?> ``` [Template Hierarchy](http://codex.wordpress.org/Templ...
40,551
<p>I have some problem making my contact form work. The contact form should only be in one simple site. So i created two templates. The first template only has the form. The other one have the php code to send a mail. But i cant make the form contact the other template</p> <p>Here is the first template</p> <pre><co...
[ { "answer_id": 40553, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 1, "selected": false, "text": "<p>How about using a plugin like <a href=\"http://contactform7.com/\" rel=\"nofollow\">contact form 7</a> or <a ...
2012/01/29
[ "https://wordpress.stackexchange.com/questions/40551", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I have some problem making my contact form work. The contact form should only be in one simple site. So i created two templates. The first template only has the form. The other one have the php code to send a mail. But i cant make the form contact the other template Here is the first template ``` <?php /* Template ...
One way to accomplish this is to setup two pages, with two [page templates](http://codex.wordpress.org/Pages#Page_Templates), one with your form code and the other with your mail code. The form action would point to the permalink of the page whose template hosts the mail code. That said, I'd actually recommend using a...
40,560
<p>I think i've almost got my head around this ajax is Wordpress business, thoroughly ejoying learning it but i'm now totally stumped.</p> <p>First up is the nasty bits! I have these in my main plugin file:</p> <pre><code>wp_enqueue_script( 'function', plugin_dir_url( __FILE__ ) . 'function.js', array( 'jquery', 'jso...
[ { "answer_id": 40593, "author": "Jared", "author_id": 2415, "author_profile": "https://wordpress.stackexchange.com/users/2415", "pm_score": 2, "selected": false, "text": "<p>In your jQuery, maybe try something like this:</p>\n\n<pre><code>jQuery( document ).ready( function() {\n\n jQu...
2012/01/29
[ "https://wordpress.stackexchange.com/questions/40560", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12364/" ]
I think i've almost got my head around this ajax is Wordpress business, thoroughly ejoying learning it but i'm now totally stumped. First up is the nasty bits! I have these in my main plugin file: ``` wp_enqueue_script( 'function', plugin_dir_url( __FILE__ ) . 'function.js', array( 'jquery', 'json2' ) ); wp_localize_...
Look at the top of your generated HTML source code. Are you seeing something like this: ``` <script type='text/javascript'> /* <![CDATA[ */ var MyAjax = {"ajaxurl":"http:\/\/localboast\/home\/wp2\/wp-admin\/admin-ajax.php"}; /* ]]> */ </script> ``` wp\_localize\_script now escapes whatever you pass into it. So that ...
40,565
<p>After a major site review, we've created a new link and category structure to better accommodate URLs and content for the long-term. While we roll out the change, we need to avoid broken links and SEO issues because our category structure is changing.</p> <p>While best practice is to implement a 301 redirect, is th...
[ { "answer_id": 40593, "author": "Jared", "author_id": 2415, "author_profile": "https://wordpress.stackexchange.com/users/2415", "pm_score": 2, "selected": false, "text": "<p>In your jQuery, maybe try something like this:</p>\n\n<pre><code>jQuery( document ).ready( function() {\n\n jQu...
2012/01/29
[ "https://wordpress.stackexchange.com/questions/40565", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12175/" ]
After a major site review, we've created a new link and category structure to better accommodate URLs and content for the long-term. While we roll out the change, we need to avoid broken links and SEO issues because our category structure is changing. While best practice is to implement a 301 redirect, is there a solu...
Look at the top of your generated HTML source code. Are you seeing something like this: ``` <script type='text/javascript'> /* <![CDATA[ */ var MyAjax = {"ajaxurl":"http:\/\/localboast\/home\/wp2\/wp-admin\/admin-ajax.php"}; /* ]]> */ </script> ``` wp\_localize\_script now escapes whatever you pass into it. So that ...
40,566
<p>So, here is some code I came up with -- It works, but now I need it to send the username and password it generated to that email address automatically ?? Also the first and last name isn't recording ?? Thanks!!</p> <pre><code>require('wordpress/wp-blog-header.php'); $user_email = trim(isset($_POST['payer_email']) ...
[ { "answer_id": 40567, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 2, "selected": false, "text": "<p>There's the <code>user_register</code> hook, which runs at the end of user insertion and has $user_id as a pa...
2012/01/29
[ "https://wordpress.stackexchange.com/questions/40566", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11572/" ]
So, here is some code I came up with -- It works, but now I need it to send the username and password it generated to that email address automatically ?? Also the first and last name isn't recording ?? Thanks!! ``` require('wordpress/wp-blog-header.php'); $user_email = trim(isset($_POST['payer_email']) ? $_POST['paye...
You can use this: `wp_new_user_notification( $user_id, $random_password);`
40,574
<p>How do auto populate the excerpt field with the first 15 words of the post content? I found this snippet: </p> <pre><code>function wps_excerpt_content( $content ) { $content = "YOUR EXCERPT HERE"; return $content; } add_filter( 'default_excerpt', 'wps_excerpt_content' ); </code></pre> <p>But I don't know h...
[ { "answer_id": 40575, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 3, "selected": true, "text": "<p>How about using the <a href=\"http://codex.wordpress.org/Plugin_API/Filter_Reference/excerpt_length\" rel=\"no...
2012/01/29
[ "https://wordpress.stackexchange.com/questions/40574", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1905/" ]
How do auto populate the excerpt field with the first 15 words of the post content? I found this snippet: ``` function wps_excerpt_content( $content ) { $content = "YOUR EXCERPT HERE"; return $content; } add_filter( 'default_excerpt', 'wps_excerpt_content' ); ``` But I don't know how to modify it with what ...
How about using the [`excerpt_length`](http://codex.wordpress.org/Plugin_API/Filter_Reference/excerpt_length) filter? ``` function my_excerpt_lenght( $length ) { return 15; } add_filter( 'excerpt_length', 'my_excerpt_lenght', 999 ); ```
40,576
<p>Just posted a new plugin: <a href="http://wordpress.org/extend/plugins/wp-qr-code-login/" rel="nofollow">No More Passwords</a></p> <p>I currently have it tagged beta because logging into a platform is a sensitive issue and I don't want to release something that may have security holes. So here's my query:</p> <p>I...
[ { "answer_id": 40575, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 3, "selected": true, "text": "<p>How about using the <a href=\"http://codex.wordpress.org/Plugin_API/Filter_Reference/excerpt_length\" rel=\"no...
2012/01/29
[ "https://wordpress.stackexchange.com/questions/40576", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2165/" ]
Just posted a new plugin: [No More Passwords](http://wordpress.org/extend/plugins/wp-qr-code-login/) I currently have it tagged beta because logging into a platform is a sensitive issue and I don't want to release something that may have security holes. So here's my query: Is is secure? I've done the following to en...
How about using the [`excerpt_length`](http://codex.wordpress.org/Plugin_API/Filter_Reference/excerpt_length) filter? ``` function my_excerpt_lenght( $length ) { return 15; } add_filter( 'excerpt_length', 'my_excerpt_lenght', 999 ); ```
40,595
<p>Im trying to echo the content from inside shortcodes into a conditional. I have two shortcodes like this:</p> <pre>function fb_fans( $atts, $content = null ) { return $content; } add_shortcode( 'fans', 'fb_fans' ); function fb_nonfans( $atts, $content = null ) { return $content; } add_shortcode( 'nonfans', 'fb_non...
[ { "answer_id": 40588, "author": "Jared", "author_id": 2415, "author_profile": "https://wordpress.stackexchange.com/users/2415", "pm_score": 1, "selected": false, "text": "<p>You could simply <code>include</code> the WordPress main file that it loads, <code>wp-load.php</code> or <code>wp-...
2012/01/30
[ "https://wordpress.stackexchange.com/questions/40595", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12571/" ]
Im trying to echo the content from inside shortcodes into a conditional. I have two shortcodes like this: ``` function fb_fans( $atts, $content = null ) { return $content; } add_shortcode( 'fans', 'fb_fans' ); function fb_nonfans( $atts, $content = null ) { return $content; } add_shortcode( 'nonfans', 'fb_nonfans' );...
You could simply `include` the WordPress main file that it loads, `wp-load.php` or `wp-blog-header.php` at the very top of your forum's header file. If I'm correct, that should allow you to use WordPress functions inside your forum theme. Example, at the top of your header, assuming the forum folder is in the root WP...
40,620
<p>When I search on my site it currently doesn't search the content in my custom meta boxes.</p> <p>How can I include this content when searching?</p> <p>I'm registering my meta boxes as follows:</p> <pre><code>$meta_box['recipe'] = array( 'id' =&gt; 'recipe-meta-details', 'title' =&gt; 'Recipe Meta Details'...
[ { "answer_id": 40638, "author": "Olaf", "author_id": 9996, "author_profile": "https://wordpress.stackexchange.com/users/9996", "pm_score": 2, "selected": true, "text": "<p>try the <a href=\"http://wordpress.org/extend/plugins/relevanssi/\" rel=\"nofollow\">Relevanssi</a> plugin.</p>\n" ...
2012/01/30
[ "https://wordpress.stackexchange.com/questions/40620", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1063/" ]
When I search on my site it currently doesn't search the content in my custom meta boxes. How can I include this content when searching? I'm registering my meta boxes as follows: ``` $meta_box['recipe'] = array( 'id' => 'recipe-meta-details', 'title' => 'Recipe Meta Details', 'context' => 'normal', '...
try the [Relevanssi](http://wordpress.org/extend/plugins/relevanssi/) plugin.
40,642
<p>What is the right way to put in Open Graph Protocol into a wp theme in order to when someone likes or shares on facebook to show hihm as thumbnail the featured image of the post or the page?</p> <p>Which is the metadata that need to be written in the header.php or function.php?</p>
[ { "answer_id": 40674, "author": "Axeva", "author_id": 10328, "author_profile": "https://wordpress.stackexchange.com/users/10328", "pm_score": 0, "selected": false, "text": "<p>You don't necessarily need a 3rd party plugin to get the benefits of Open Graph, but without writing some code, ...
2012/01/30
[ "https://wordpress.stackexchange.com/questions/40642", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12508/" ]
What is the right way to put in Open Graph Protocol into a wp theme in order to when someone likes or shares on facebook to show hihm as thumbnail the featured image of the post or the page? Which is the metadata that need to be written in the header.php or function.php?
This information doesn't have to be static. Here's an example: ``` <meta property="og:title" content="<?php if ( is_single() ) { wp_title(); } else { bloginfo('name'); } ?>" /> <meta property="og:type" content="blog" /> <meta property="og:url" content="<?php echo get_permalink() ?>" /> <meta property="og:site_name" co...
40,650
<p>A few basic questions to accelerate my wordpress plugin development start. I'd like to develop a wordpress plugin that adds some javascript and css to a specific page. What filters or actions should be used? How to restrict execution of a plugin to a single (known) page? How can a plugin add some content to a page?...
[ { "answer_id": 40651, "author": "Azizur Rahman", "author_id": 3797, "author_profile": "https://wordpress.stackexchange.com/users/3797", "pm_score": 0, "selected": false, "text": "<p>Take a look at <a href=\"http://wordpress.org/extend/plugins/page-specific-cssjs/\" rel=\"nofollow norefer...
2012/01/30
[ "https://wordpress.stackexchange.com/questions/40650", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12311/" ]
A few basic questions to accelerate my wordpress plugin development start. I'd like to develop a wordpress plugin that adds some javascript and css to a specific page. What filters or actions should be used? How to restrict execution of a plugin to a single (known) page? How can a plugin add some content to a page?
WordPress has a built-in function called [wp\_enqueue\_script()](http://codex.wordpress.org/Function_Reference/wp_enqueue_script) which will allow a certain piece of JavaScript to be included in a page. If you'd just like to see that script on a particular page, you can conditionally call it from the theme file. For ex...
40,666
<p>What's the best way to achieve this: I have local videos on my server, but if I use the WP add media button I just get a link to a video, rather than it embedded. Are there any good plugins which will let me embed local video? Everything seems to support video sharing from Google, YouTube, Vimeo etc.</p>
[ { "answer_id": 40673, "author": "goldenapples", "author_id": 290, "author_profile": "https://wordpress.stackexchange.com/users/290", "pm_score": 0, "selected": false, "text": "<p>It probably depends what format your videos are in.</p>\n\n<p>For most cases, I'd recommend <a href=\"http://...
2012/01/30
[ "https://wordpress.stackexchange.com/questions/40666", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10745/" ]
What's the best way to achieve this: I have local videos on my server, but if I use the WP add media button I just get a link to a video, rather than it embedded. Are there any good plugins which will let me embed local video? Everything seems to support video sharing from Google, YouTube, Vimeo etc.
You can try this: Use JWPlayer or Flowplayer or whichever videoplayer you like. You can also use <http://videojs.com/> which will give you the ability to automatically change from html5 to flash player and it's free and even hosted by them. Now, from their own example: ``` <video id="my_video_1" class="video-js vjs-d...
40,667
<p>Is there a simple way to prevent all caching when testing the appearance of changes to the site? I use WP Super Cache. I can delete its cache using the option provided, delete the cache for my browser, and still some changes to CSS or widgets do not refresh. I try other work-arounds like switching browsers or compu...
[ { "answer_id": 40669, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 6, "selected": true, "text": "<p>Add the <code>filemtime()</code> of your stylesheet as version parameter. Lets say, your default stylesheet is in <code...
2012/01/30
[ "https://wordpress.stackexchange.com/questions/40667", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10120/" ]
Is there a simple way to prevent all caching when testing the appearance of changes to the site? I use WP Super Cache. I can delete its cache using the option provided, delete the cache for my browser, and still some changes to CSS or widgets do not refresh. I try other work-arounds like switching browsers or computers...
Add the `filemtime()` of your stylesheet as version parameter. Lets say, your default stylesheet is in `css/default.css` and `css/default.min.css` ([not `style.css`](https://wordpress.stackexchange.com/a/111505/73)). When we register a stylesheet on `wp_loaded` ([not `init`](https://wordpress.stackexchange.com/a/67635/...