question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
My site needs to integrate with a 3rd party software, which will live on its own sub-domain, hosted by the software company. I need to provide the 3rd party developers with an endpoint that they can use to make API calls (to my wordpress site) in order to allow my site's users to access the sub-domain. The other site n...
Cross-site Scripting Issues You cannot transfer WP auth cookies between domains. You also don't want to store plaintext passwords for logging into another WP installation programmatically. So, you'll have to have users log into WordPress, and then access their login status via an API endpoint from the third-party site....
Create API for single sign-on with 3rd party site
wordpress
The function below lists posts based on custom field. The result is involved in a list <code> &lt;li&gt;&lt;/li&gt; </code> . What I would like to do is count how many list items there are, then divide it into two ul's. Is there any way to split the result into two columns? <code> function article_series() { global $po...
You could do this with the modulo operator. <code> $posts = get_posts($args); $html = '&lt;ul&gt;'; $limit = 5; $i = 1; foreach ($posts as $post) { $html .= '&lt;li&gt;' . $post-&gt;post_title . '&lt;/li&gt;'; if($i % $limit == 0) { $html .= '&lt;/ul&gt;&lt;ul&gt;'; } $i++; } $html .= '&lt;/ul&gt;'; echo $html; </code>
Divide the list into two columns (get_posts)
wordpress
Is there a way to get the results of a loop with a filter before the code for the loop is performed in the structure of your code? My markup is something like this: <code> &lt;body&gt; &lt;div&gt; /* can I use a function to get the results from a loop performed after this point with a filter or hook of some sort */ &lt...
@Rutwick's answer was what I thought when I read the title, but I think you're just wanting to use <code> get_the_terms() </code> which can be out of the loop like this: <code> $my_post_terms = get_the_terms( $post-&gt;ID, 'show' ); if( $my_post_terms &amp;&amp; !is_wp_error( $my_post_terms ) ) { // do something here w...
Way of getting queried loop before the query with a filter hook?
wordpress
I've installed the wp_pagination plugin and it appears to be working fine at the bottom of the page , however, the pagination is not displaying at the top of the page. Below is the template code: <code> &lt;?php /* Template Name: Press */ get_header(); ?&gt; &lt;div id="primary"&gt; &lt;div id="content" role="main"&gt;...
<code> query_posts() </code> overwrites the original query, and the pagination gets the original before the <code> query_posts() </code> call and the changed after it. Solution: Don’t use <code> query_posts() </code> , filter <code> pre_get_posts </code> instead. We have stackexchange-url ("tons of examples") for that ...
wp_pagination not displaying at top of page
wordpress
My clients has recently had a problem with spam posts being added to their blog, under various usernames. The users have been deleted, but Wordpress is not able to remove the posts from the trash. Using the 'Empty Trash' button does not work either. Removing directly from the database appears to work, but as there are ...
Technically, defining <code> define('EMPTY_TRASH_DAYS', 0 ); </code> in <code> wp-config.php </code> file should delete whatever is in Trash after zero days. I just tried it, but didn't work immediately. I may have to wait for a day to see the result.
Problem deleting posts from trash
wordpress
I'm making a login form for my site, and I've this section: <code> &lt;?php if (is_user_logged_in()) { echo 'Hello, ', $user_login, '. &lt;a href="', wp_logout_url(), '" title="Logout"&gt;Logout&lt;/a&gt;'; } else { wp_login_form(); } ?&gt; </code> And after loggin in, it returns to the page with no indication of loggi...
There's nothing wrong with the function, it's the fact that you aren't actually being logged in! You say you're making your own login form? Does this post to the standard <code> wp-login.php </code> , or do you handle the request yourself? Does the path/domain of the form differ from WordPress? If you inspect your cook...
is_user_logged_in() isn't working
wordpress
I've been using the new theme customizer and it really has me thinking how awesome it would be to allow potential theme buyers/clients etc to play with the customizer for a demo theme (without being logged in). The customizer is located at : <code> ..wp-admin/customize.php </code> . So what it would take would be to so...
Just an idea: Make a user called 'Guest' and look up the user ID When redirecting your potential clients to the admin page, redirect to a script that's logging in your clients as the guest user (Code #1) Add an WordPress action to disallow the user when logged in as 'Guest' and not on customize.php (Code #2) Code #1 <c...
Is it possible ( or advisable) to allow open access to the new theme customizer for potential clients?
wordpress
I know my way around WP as probably an intermediate user. In the near future, I will have to integrate the design of a template from a completely different theme into a theme I'm currently using. The idea is to keep the look of the front page of one theme the same, and the use the design of another theme's regular blog...
Think Twice I have to start by saying that this seems like a really odd idea. Having a front page that's totally different from the rest of the site will break a lot of user expectations and cause confusion. Is it really two completely different themes or do you just want a custom layout on the front page? If the latte...
Putting two themes together to create a complete site
wordpress
I have a problem with a shortcode that I'm creating. I have 5-10 different custom post types, and rather than creating a template for every individual post type, Id rather use a normal page and import the posts via a shortcode. So to explain further, I have a page called Attractions and a post type called 'Attraction'....
ok, i still don't love the idea of a second query, but you're right it is hard to add content to the archives pages. there were 3 problems that i found: next_posts_link and previous_posts_link both echo, you need their get_ equivalents. when you look up get_next_posts_link, you find that it relies on the global $wp_que...
Shortcode Displaying Custom Post Types
wordpress
I have some code that updates a meta-key's value by incrementing... <code> $post_id = $wpdb-&gt;get_var( $query ); $meta = get_post_meta( $post_id, 'stuff', TRUE ); $meta++; update_post_meta( $post_id, 'stuff', $meta ); </code> I want to create and save a revision of the meta key/ value each time it is updated, so I ca...
You'd need to set up an additional custom field and update it whenever the user changes or updates the original custom field.
Saving Revision of post meta key/value on each update_post_meta event
wordpress
Is there a way to dump a list of all meta keys being used by all posts belonging to a custom post type? I.e., a post-type named foods, each food (ham, spaghetti, chicken), can have a different meta key, which is generated dynamically. I can't know which meta keys have been added, but I'd like to be able to use a list o...
You can use a simple query to get a distinct list of user-entered meta_keys for a specific post type, then cache the results using the Transients API. The meta keys from this query will be those that do not start with an underscore or number. <code> function generate_foods_meta_keys(){ global $wpdb; $post_type = 'foods...
Echo all meta keys of a custom-post TYPE
wordpress
I'm adding some fields to attachment edit form by add filter to "attachment_fields_to_edit". The added fields work fine but they are not rendered as the order I added them. Is there a way to order the fields?
Yes there is. Add css styles for the form or more precisely try to add names in class attribute of the fields. This should help to properly render the order. For this you may want to check the class names of existing fields which was rendered correctly.
How to set order for attachment form field?
wordpress
I have made a custom menu handler for the back end, sorting the via a drag drop based on CMS Page Order . The problem now is that it seems that it's not possible to sort wp_nav_menu in any other way than the default one, can that be really be true?
The nav_menu_items are already sorted by menu_order. When you go into the Appearance -> Menus and arrange the order menu the menu_order of each menu item gets updated. To change the orderby parameter in the query that displays the menu you can use pre_get_posts to alter it. Example: <code> add_action( 'pre_get_posts', ...
Sort wp_nav_menu() by menu order
wordpress
I am trying to create a function for my functions.php file that will allow me to convert a post name into a post id. I have had a look around online and managed to find this link http://www.devdevote.com/cms/wordpress-hacks/get_id_by_post_name which gives the following example.. <code> function get_id_by_post_name($pos...
Use <code> get_page_by_title() </code> . It works with any post type. <code> $post = get_page_by_title( $post_name, OBJECT, 'post' ); echo $post-&gt;ID; </code>
Convert post name into post ID
wordpress
I have an image which should be output on the page. The space is limited (width-max = 209px). Now I have to provide the image in a scaled size, if the user doesn't do it. This is my code: <code> $src = wp_get_attachment_image_src($logo, 'full'); $width = $src[1]; $height = $src[2]; $new_width = 200; $factor = $width/$n...
The real workhorses behind <code> wp_get_attachment_image_src </code> are <code> image_downsize </code> &amp; <code> image_get_intermediate_size </code> . Between the two, they'll attempt to find the largest image available that fits within the constraints of the required size . The return value of <code> wp_get_attach...
wp get attachment image always gives me thumbnail
wordpress
I am planning to use the Redirection plugin to do redirects. The plugin's description states that it also enables 302 redirects, but I can't see how. There's no option as such (see screenshot below). Am I looking in the wrong place? Does anyone know how to do 302 redirects using Redirections plugin?
Considering that Redirection plugin is broken in parts, I am currently thinking of... #1 Using Simple URLs plugin by StudioPress. It adds a new custom post type to your Admin menu, where you can create, edit, delete, and manage URLs. It stores click counts in the form of a custom field on that custom post type, so it s...
How to do 302 redirects "in" WordPress using Redirection plugin?
wordpress
I'm trying to create a submenu page for reordering posts/pages. Right now I'm trying to include the list that display the different post statuses, for example: <code> All (5) | Published (4) | Draft (1) </code> I was digging around in edit.php and found that it pulls the list like this: <code> $wp_list_table-&gt;views(...
The class used in <code> edit.php </code> is an extension of the WP_List_Table: <code> WP_Posts_List_Table </code> . See <code> wp-admin/includes/class-wp-posts-list-table.php </code> . And here you find a call to <code> wp_count_posts( $type = 'post', $perm = '' ) </code> . The first parameter is for the post type, th...
Getting the different post statuses + count like in edit.php, in a custom submenu page
wordpress
i am building a News site. I want to display 1 featured post from "prime" category for only few hours. after it should be expired or disappeared from the section. please have a look here u can see the post on top. <code> &lt;div id="prime_news" class="col-full"&gt; &lt;?php $the_query = new WP_Query('category_name=prim...
Check the time parameter on WP_Query Class . There is a example on how to show posts form last 30 days. You can do it for last couple of hours, minutes or even seconds! Code is tested and working. <code> $args = array( 'posts_per_page' =&gt; 1, // We are showing only one post 'category_name' =&gt; 'prime' // showing fo...
How to display Section for certain time
wordpress
I'm pulling custom posts by their meta_key using this function: <code> &lt;?php $args = array( 'numberposts' =&gt; 10, 'meta_key' =&gt; 'allvotes', 'orderby' =&gt; 'meta_value', 'order' =&gt; 'DESC', 'post_type' =&gt; 'things', 'post_status' =&gt; 'publish' ); $mystuff = get_posts( $args ); ?&gt; </code> I want to invo...
Don't put your variables in single quotes. This: <code> if(isset($submit)){ $args = array( 'numberposts' =&gt; 10, 'meta_key' =&gt; '$filter', 'orderby' =&gt; 'meta_value', 'order' =&gt; 'DESC', 'post_type' =&gt; 'things', 'post_status' =&gt; 'publish' ); $mystuff = get_posts( $args ); $name = $filter ; } </code> Shoul...
Using Form to alter PHP variable
wordpress
I want to show the related (archive) month and year for a post next to its contents, i.e. "Archived in January 2012". Any help / directions is greatly appreciated.
Use following code after the loop: <code> $month_num = get_the_date('n'); $month_txt = get_the_date('F'); $year = get_the_date('Y'); // change 'posts_per_page' to any value you need, '-1' means 'all' query_posts( 'posts_per_page=-1&amp;monthnum='.$month_num.'&amp;year='.$year ); echo '&lt;p class=""&gt;Archived in '.$m...
Show related (archive) month and year to post
wordpress
I want to display my categories in tabs. All is good, except my "Upcoming Events", created with Event Organiser (awesome plugin at http://wordpress.org/extend/plugins/event-organiser/ ), are not being treated like a normal category, so they don't appear. In essence, get_categories() is not returning the events category...
Event categories are terms in a custom taxonomy, 'event-category', so you should use <code> get_terms </code> instead: <code> //Args for which terms to retrieve $args = array('type'=&gt; 'post', 'order' =&gt; 'ASC', 'hide_empty' =&gt; 1 ); //Array of taxonomies from which to collect the terms $taxonomies = array('event...
How to use get_categories() with Event Organiser plugin
wordpress
This is a follow up to stackexchange-url ("this question"), in witch the jpg compression is altered depending on what WP's built-in image resulting image size returns. While it may work for most of the people, i'm looking for a more discrete and automatic approach. And that is altering the <code> wp_create_thumbnail </...
i'm looking for a more discrete and automatic approach. And that is altering the <code> wp_create_thumbnail </code> i think. And that is where you'd be wrong. Here is the entire code for <code> wp_create_thumbnail() </code> from core: <code> function wp_create_thumbnail( $file, $max_side, $deprecated = '' ) { if ( !emp...
Autogenerated Thumbnail compression depending on size
wordpress
I am writing my first wordpress plugin which inserts a visualization widget inside a post. I am planning to use a shortcode for my plugin. I followed an excellent tutorial about writing shortcodes . But I still have one question in mind. I have many configuration parameters that will be associated with my widget for ex...
It sounds like your function that your shortcode is working with has a lot of parameters that it can take. In general, I definitely think the better option is to use attributes for each parameter you want to control. As you know from that tutorial, shortcodes can have default values defined for the variables and use th...
Which is a better practice when writing shortcodes: pack lots of configuration parameters or just give an id?
wordpress
Making a plugin to make my life easier at creating over 3000+ pages. Take a look at the code I have so far. <code> if (isset($_POST['action'])) { $one = array( 'post_title' =&gt; $_POST['title'], 'post_date' =&gt; $_SESSION['cal_startdate'], 'post_content' =&gt; 'This is a post.', 'post_status' =&gt; 'publish', 'post_t...
You are most likely not assigning the right page template. Make sure your template name is the same case as the file in your theme directory. Also make sure the file name you provide as the template actually exists in the theme directory otherwise it will be marked as the Default page template.
update_post_meta not working
wordpress
Can I use this snippet to retrieve posts from a custom taxonomy in a custom post type? <code> &lt;?php $sermon_series = new WP_Query( array('series' =&gt; 'type')); ?&gt; &lt;?php while ($sermon_series-&gt;have_posts()) : $sermon_series-&gt;the_post(); ?&gt; &lt;li&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt...
Reference: <code> WordPress Codex — Custom Taxonomies &gt; Querying by taxonomy </code> Creating a taxonomy generally automatically creates a special query variable using WP_Query class, which we can use to retrieve posts based on. For example, to pull a list of posts that have "Bob" as a "person" taxonomy in them, we ...
Display related custom taxonomy posts in sidebar
wordpress
I want to move from Wordpress hosting to self-hosting. I have installed wordpress on my self-host account. Now I want to play with it for a while with themes,plugins, etc. and see how it goes. So I am thinking of bringing all my post to my account. I would like my original blog on wordpress to work as usual for now unt...
It's just a copy of your posts.
Does doing an export moves all my posts or just a copy of it?
wordpress
I changed theme/plugin now the post content still display shortcodes. There are some tips around on hiding them, but everytime I use some content functions, the shortcodes shows up again. Also, my shortcodes are the "extended type" such <code> [theshortcode id="34877"] </code> , <code> [theshort size="large" "tiny"] </...
Please backup your database before trying In your current theme, open the <code> functions.php </code> file and add the code below. In <code> theshortcodeyouhate </code> inform the shortcode you want to get rid of, note that even extended types works nicely! Once you added this code, hit F5 and you are done. <code> add...
How to get rid of shortcodes in post content once and for all
wordpress
I have a site that has a Wordpress blog section. I would like to enable Single Sign On in the site so that on logging onto my site, the WP blog also logs on on simultaneously. I have two user tables. One for the site, other for the WP part. What I did was add a curl along with the function for logging on the site's blo...
<code> $username = $_POST['username']; $password = $_POST['password']; define('__ROOT__', dirname('public_html')); require_once (__ROOT__.'/blog/wp-load.php'); $credentials = array('user_login' =&gt; $username, 'user_password' =&gt; $password); $user = wp_signon($credentials,$secure_cookie); </code> This is the code th...
Single sign on with custom site
wordpress
In my template file, I loop through posts that are categorized either web , print , or marketing in a custom taxonomy portfolio . How do I echo the slug of each posts category?
This shouldn't be too hard! <code> $my_terms = get_the_terms( $post-&gt;ID, 'portfolio' ); if( $my_terms &amp;&amp; !is_wp_error( $my_terms ) ) { foreach( $my_terms as $term ) { echo $term-&gt;slug; } } </code>
How do I get the slug of a custom taxonomy category of a post?
wordpress
I'd like to have a non-hierarchical custom taxonomy displayed in the add/edit posts admin screen for a custom post type. Obviously, when the custom taxonomy is non-hierarchical, the meta box that's displayed is similar to the tags - it's a text field with the auto-suggest. However, I'm more interested in having a flat,...
I'm not sure, if you already found a solution for this, but when I searched for a similar one yesterday, I found this tutorial on WPtuts very helpful. It uses radio buttons, but you can easily modify it to get it working with checkboxes as well. http://wp.tutsplus.com/tutorials/creative-coding/how-to-use-radio-buttons-...
How to display non-hierarchical taxonomy as terms with checkboxes?
wordpress
Is there a Conditional Tag, or any other method, that we can use to check if we are customizing the theme? I want to include some extra stylesheet while customizing the theme. so I'd like to have sth like: <code> if ( theme-customizer-is-active ) { // load some extra styles } </code>
As in this question: stackexchange-url ("How to execute conditional script when on new customize.php (Theme Customize) screen") <code> global $wp_customize; if ( isset( $wp_customize ) ) { // do stuff } </code>
Way to check if we are in Theme Customizer mode?
wordpress
I am new in Wordpress and what I really can't find how to do is the following: I have a new Page created from the CMS. This pages have different modules with text. Take for example this template http://www.templatemonster.com/demo/40000.html There are three modules in the row with an icon, a heading and text. And below...
The example you gave has a listing of three pages and four posts (which are dated). The same can be achieved by one of the following: two different Custom Post Types , one per block, e. g. <code> post_type='products' </code> and <code> post_type='projects' </code> ; children of two another pages, e. g. children of "Pro...
Multiple areas of dynamic content in a page
wordpress
I'm writing a child theme for Genesis and trying to figure out to get the full image sizes on "Genesis - Featured Posts" widget. The widget has a check box "Show Featured Image" and "Image Size" options of following values. <code> thumbnail (150x150) featured-image(150x100) </code> The options have thumbnail sizes and ...
A simple function which would add additional image size. <code> /* * add_image_size( 'post-thumbnail', $width, $height, $crop ); * 280x254 */ add_image_size( 'additional-image-size', 800, 600, false ); </code> This function will add additional image size of width 800px and height 600px this function can be used in chil...
Select full Image Size on widget "Genesis - Featured Posts"
wordpress
I want to get second level terms of a specific parent (first-level) term in a custom taxonomy. Sounds complicated but would be useful. <code> Term 1 SubTerm-1.1 SubTerm-1.2 SubTerm-1.2.1 Term 2 SubTerm-2.1 </code> Say, if <code> SubTerm-&gt;parent </code> is Term 1's id, then i want to output SubTerm 1.1 and 1.2 but no...
You can use PHP's <code> array_filter </code> to process the results of a taxonomy query function that returns its results, and then display them. Something like: <code> # This returns the whole taxonomy... $whole_tax = get_terms('customtax', array('hide_empty' =&gt; 0)); $second_level = array_filter($whole_tax, functi...
Get second level terms of custom taxonomy
wordpress
I have this code in WordPress index.php and I was wondering how can I transfer this in to a functions.php to be a part of a function ? <code> &lt;?php if (in_category('featured')) : ?&gt; &lt;a href="&lt;?php the_permalink(); ?&gt;"&gt; &lt;span class="featured_icon"&gt; &lt;img src="&lt;?php bloginfo('template_directo...
If you want to use the function to output the code somewhere: <code> function displayImage($currentPost) { // Show the featured icon only if current post is in "featured" category if ( in_category ( 'featured', $currentPost ) ) { $output = '&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt; &lt;span class="featured_icon"...
If in category to be inside of a function
wordpress
I have a baseball related website with multiple authors. I use the "Stick this post to the front page" to denote an "Editor's Pick" on an article. I would like to add a link/button to allow editor to do this from the front end. The method can either be in the article itself or in the Admin Bar. I do not really have a p...
I think this small source code is your solution. It currently doesn't have frontend feedback for the Sticky Post change, but you can enhance this string, class or whatever you want in the function <code> fb_stick_post </code> . The first function adds the item in the Admin Bar and creates a new Url with a param value. ...
How to add "Stick this post to the front page" to front end?
wordpress
I overrides the parent theme by copying "header.php" and "footer.php" files to the "child" folder, it is working nicely. But I wonder if I install a plugin that need to edit the "header.php" or "footer.php" files, what will happen then?? Since I override those php files, will the plugin edit the files in "child" folder...
A plugin never edits those files - WordPress uses a system of "hooks" and "filters" that allows plugins to change behaviour without altering code. So, in short, as long as you've created your child theme correctly, plugins will work fine. Some references: http://codex.wordpress.org/Child_Themes http://codex.wordpress.o...
Overriding Parent Theme... will cause plugins failure?
wordpress
What is the best way of retrieving a list of all blogs and their URLs in a MU network? Can I find them somewhere in the database? I'm also confused about the database schema. I have two different networks, one network has lots and lots and lots of tables with names such as wp_{id}_posts whereas the other network - whic...
You can use something like this <code> global $wpdb; $blogs = $wpdb-&gt;get_results( $wpdb-&gt;prepare( "SELECT blog_id, domain, path FROM wp_blogs ORDER BY blog_id" ) ); </code> Iterate through $blogs to get what you need. There is a function <code> get_blog_list() </code> , but it's been deprecated, so you probably s...
Questions about MU database schema and how to list all blogs
wordpress
I followed this tutorial for the page specific template -- http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates Created a page through wordpress admin panel - <code> Blog Page </code> URL like -- <code> http://localhost/wordpress/blog-page/ </code> and set template to my template "Swapnesh" from the admin ...
I think you're muddling up the Template Hierarchy , so make sure to start by reading that. <code> page-blog-page.php </code> is for a page with the slug "blog-page." If you're using a page template, then you should name it something outside of the template hierarchy-reserved name spaces (e.g. <code> page-{slug} </code>...
Custom page template not working
wordpress
A newbe wp_query question: I set a wp_query as follows, but instead of 17 posts I only get the first 10 posts from the selected Category with ID=5. Is there an implicit paging directive on the results? <code> $myPosts = new WP_Query(); $args_posts = array('cat' =&gt; 5); $myPosts-&gt;query($args_posts); while ($myPosts...
If you want to get all the pages instead, you should add <code> posts_per_page'=&gt;-1 </code> to your query You can have a look at the Wordpress Codex http://codex.wordpress.org/Class_Reference/WP_Query
wp_query: implicit paging? I get less posts that I should
wordpress
I have a post type called 'article' and on the article archive page i'd like to show all the articles, sorted by author. <code> function kia_adjust_the_query( $query ) { // change posts_per_page param if ( is_post_type_archive( 'article' ) ) { set_query_var('posts_per_archive_page',-1); set_query_var('order','ASC'); se...
You could do that with a custom <code> posts_orderby </code> : <code> add_filter( 'posts_orderby', 'wpa58715_posts_orderby' ); function wpa58715_posts_orderby( $orderby_statement ) { if ( is_post_type_archive( 'article' ) ) { global $wpdb; $orderby_statement = "FIELD($wpdb-&gt;posts.post_author, 42) DESC, $wpdb-&gt;pos...
Sort query by author: 1 author, then others
wordpress
EDIT: I finally got the right answer; see my own answer beneath this post for everyone that's interested. After searching for a couple of days and trying over and over again I really got stuck. I've a client who collects customer experiences on his website by using the comment form; all comments are displayed as a cust...
EDIT: With some help of a friend I came up with a solution. For everyone interested: Use a custom post-type, in my case comment_post. Then upload the images like this: <code> $new_post = array( 'post_title' =&gt; $title, 'post_content' =&gt; $comment, 'post_status' =&gt; 'pending',// Choose: publish, preview, future, d...
Upload images with comment
wordpress
In my comments.php I have this code: <code> &lt;input name="submit" type="submit" id="submit" tabindex="5" value="Submit" /&gt; &lt;?php comment_id_fields(); ?&gt; &lt;?php do_action('comment_form', $post-&gt;ID); ?&gt; </code> Is there a way to replace this code whit a simple submit form? and not use: do_action() ?
Try this: <code> &lt;?php comment_form(); ?&gt; </code> References: Function Reference for <code> comment_form(); </code> on WordPress Codex <code> comment_form(); </code> WordPress function reference, arguments and source at QueryPosts
Replace do_action() with a normal submit form in comments.php
wordpress
I have been unable to get my single-portfolio.php template to behave properly. So I have a custom post type called portfolio. I am displaying all of those posts in the front-page.php and it works perfectly fine. Here is the loop for the front-page.php: http://pastie.org/4268087 For the life of my however, I cannot get ...
If you have your custom post type rewrite rules set up properly, you shouldn't need to create a new <code> WP_Query </code> in your template file. Comment out the <code> new WP_Query </code> line or rename your <code> portfolio-single.php </code> so WP pulls from the default <code> single.php </code> and see if it pull...
Custom Post Type Single Loop Outputting Wrong Post
wordpress
I have cleared up the stackexchange-url ("first step ") on moving to Self-hosted wordpress. Now I have a confusion if someone can answer: 1: My hosting provider's tutorial shows installing WP from cPanel using tool called Softaculous. Is it a good way to use that utility or do by grabbing the wp package from wordpress....
If your already confused with using Softaculos why not go with the file source from wordpress.org which has a very very simple installtion that takes just a minute or two. You simply need to create your database, user and enter that when installing WordPress. You can set the www or non-www in WordPress itself during in...
Things to take care before installing wordpress Manual v/s Softaculous
wordpress
I have a custom post type named <code> domicile </code> . Each post (domicile) has an owner (not the author ). Owners are users with a custom role. I store the user id as a post meta value ( <code> dmb_owner </code> ) for the <code> domicile </code> post type. How do I sort the list table ( <code> wp-admin/edit.php?pos...
An 'easy' but not very good solution is to store the user's display name as well as ID, and sort by that. Obviously an update of a user's display name would prompt an update of all the domicile that user owns. Alternatively the following is an outline (untested) of what should work. The idea is to tell WordPress to sor...
Sort custom post type list table by display name of a user id stored as post meta value
wordpress
How do I go about inserting a custom div before the wp_nav_menu() adds the ul? The problem is that the script is inserting my 'div menu button' after the nav ul instead of before it. I am trying to do this via a function because the basic idea is that on some of my menus I need to insert a div with a 'menu' button for ...
Here is the solution. Props to @SergeyBiryukov Changes required turning echo to false and adding in the return $main_menu. function tumble_menu( $args = array() ) { /* Default arguments */ $defaults = array( 'container' => 'ul', 'menu_class' => 'nav', 'menu_id' => 'main_menu', 'theme_location' => 'main-menu', 'echo' =>...
Insert a div before the wp_nav_menu
wordpress
I'm looking for a way for members of my site to be able to post comments on the site's wordpress blog, and have their name and avatar from the site show up next to their comments. Is there a way to link wordpress to the site's custom login system to let the members of my site login and be able to post from their names ...
There are lots of plugins to do this. It sounds like you're looking for JetPack's rather new comment module. There are also powerful commenting plugins like Disqus and LiveFyre.
Is it possible to integrate a custom login feature with wordpress?
wordpress
How do I validate an array of emails from a textbox before sending them to the <code> wp_mail </code> function? <code> $emails = 'test@test.com;test2@test2.com email3@email3.com,email4@email4.com, email5.com'; $emails = preg_split('/[;,\n]/', $emails); $validEmails = array(); $subject = 'Hey Subject'; $message = 'I am ...
Are you aware you can pass a comma-separated string of email adresses to <code> wp_mail </code> ? <code> // Make sure your email strings only uses comma as a separator $emails = preg_replace('~[,;\s]+~', ',', $emails); </code> Then just throw that string into <code> wp_mail </code> ’s first argument. Depending on exact...
Validate emails in array using foreach
wordpress
I want to create a public front-end profile page with a friendly url like this format. <code> mysite.com/user/someusername </code> Any idea on how can i achieve this? I know it has something to do with rewrite rule but i have no idea on how can i do that. If you got any link or tutorial for me that will be great. Thank...
There are two ways I've discovered doing this: Author Page with a custom rewrite rule A custom template files paired with a rewrite rule The first is more simple to implement, but may not work in all circumstances (one of which I'll describe soon). Custom Rewrite Rule I found this solution a few days ago here: stackexc...
How to create a front end user profile with a friendly permalink
wordpress
After someone submits a comment this line of codes redirects him to the post (i believe). Can I modify the code in order to redirect him to a custom URL? do_action('comment_form', $post-> ID) Ty for the answer, UPDATE: my comments.php <code> &lt;form&gt; ....... &lt;input name="submit" type="submit" id="submit" tabinde...
Not quite; the redirect occurs inline inside <code> wp-comments-post.php </code> Use the filter <code> comment_post_redirect </code> to pass back any URL of your choice. Arguments passed are the default redirect &amp; comment object, respectively. Based on your comments, here's a suggestion: <code> add_filter( 'comment...
Redirect user to a custom url after submitting the comment
wordpress
So I have a problem when making a post. If I press enter and make a new line in the editor and press safe the line break diapers. But when I show the post it have inserted a line break. So somehow the editor is not able to show the line break? If I save the editor again the line break disappears from the post as well. ...
Ah sorry I just realized that I had margin: 0 on all elements to reset all defaults in browsers... this caused the issue!
line break are not working when editing a post
wordpress
Short. I want ''large' images compressed by 90%, and 'medium' to be by 60%. Has many af you know, sometimes larger images suffer from high compression, but other small images don't. This function allows to resample all the jpg images <code> function custom_jpg_compression($args) { return 90; } add_filter('jpeg_quality'...
A very special filter The <code> jpeg_quality </code> filter is a really special one: It gets used in three different cases and you've to use the second argument to determine, if you want to use the filter or not. Don't let it do everything The main problem for such a special filter is, that it may fire for later actio...
Changing JPEG compression depending on image size
wordpress
Is there a straightforward way to share/sync multiple WP instances with a single database? I work collaboratively with several developers on custom themed sites. We use git to keep our files in order and it's all fine in the early stages, but once content, plugins etc. start coming into play, we have issues with stayin...
Yes. Use <code> WP_HOME </code> and <code> WP_SITEURL </code> in your <code> wp-config.php </code> , so the URLs in the database won't mess (a lot) with local site development. <code> define ('WP_HOME', 'http://local/site/url'); define ('WP_SITEURL', 'http://local/site/url'); </code> Also, some other good practices: Pu...
Sharing database for collaborative development
wordpress
I want to have an auto-complete or auto-suggest function on a (search) form: When a user begins to type, it suggests post titles that have matching text. I'd also like it to display some meta-data (a number) that I have stored related to each custom post. Example: If I type "A", it suggest "Apples (13), Aardvarks(51), ...
Yes this is possible. You can use jQuery Auto Suggest which is included with WordPress http://codex.wordpress.org/Function_Reference/wp_enqueue_script With this you can write a form that does a Ajax lookup to the the Ajax URL handler. Which you can add_action onto. http://codex.wordpress.org/AJAX_in_Plugins So you can ...
Auto-complete or auto-suggest from list of post titles
wordpress
I have a Wordpress network installed, and the first website I created is not listed under the Sites entry in the top horizontal menu. The second website I created is, along with the parent website. If I go to Network > Sites, the first website is listed, and I can use the website fine, provided I type in the URL direct...
I found the cause. Under Network > Sites, there were no users listed next to the website in question. My user account was listed next to the other two websites. So, adding my user account as an administrator of the website added it back to the Sites menu. I am not sure why my user account was not an administrator alrea...
Website not listed under Sites (in a Network environment)
wordpress
Need some help here. I've been working on a widget to display a list of featured posts (custom post type) and want to display the featured image for each post so I was using the_post_thumbnail call with a custom thumbnail size included as the parameter and for some strange reason, the call is removing some of the HTML ...
<code> the_post_thumbnail(); </code> function is not supposed to be <code> echo </code> -ed! <code> get_the_post_thumbnail(); </code> is meant for that. Refer to the linked WordPress Codex pages. Try this instead: <code> &lt;?php // Wraps post-thumbnail in li tags echo ' &lt;li&gt;' . get_the_post_thumbnail('talent-fea...
the_post_thumbnail call removing li in code
wordpress
I'm using wordpress' built in suggest scripts to create an auto-suggest form based on custom post titles... add_action('wp_enqueue_scripts', 'se_wp_enqueue_scripts'); function se_wp_enqueue_scripts() { wp_enqueue_script('suggest'); } add_action('wp_head', 'se_wp_head'); function se_wp_head() { ?> var se_ajax_url = ''; ...
Change the jQuery: <code> jQuery('#stuff-input').suggest(se_ajax_url + '?action=se_lookup', { onSelect: function() { thevalue = this.value; thevalue = thevalue.split(' ('); jQuery('#stuff-input').val(thevalue[0]); } }); </code>
Auto-suggest to display meta-data, but not to include it upon click
wordpress
I already have a function where a user submits a form and creates a custom post... <code> &lt;?php $postTitle = $_POST['post_title']; $submit = $_POST['submit']; if(isset($submit)){ global $user_ID; $new_post = array( 'post_title' =&gt; $postTitle, 'post_content' =&gt; '', 'post_status' =&gt; 'publish', 'post_date' =&g...
This would need a query. So building on your code: <code> &lt;?php $postTitle = $_POST['post_title']; $submit = $_POST['submit']; if(isset($submit)){ global $user_ID, $wpdb; $query = $wpdb-&gt;prepare( 'SELECT ID FROM ' . $wpdb-&gt;posts . ' WHERE post_title = %s AND post_type = 'stuff'', $postTitle ); $wpdb-&gt;query(...
Check if Post Title exists, Insert post if doesn't, Add Incremental # to Meta if does
wordpress
I have a query regarding managing a wordpress setup, I am sure others have been in a similar situation and was wondering what would be the best solution. I manage an annual festival's website, each year has a different theme / design and event details, this is archived each year [ ie at festival.com/2008/ etc.] Last ye...
Personally. I would archive the 2010/etc sites to Pure HTML. This plugin would do the job http://wordpress.org/extend/plugins/static-html-output-plugin/ This WordPress codex post describes another method. With using WordPress in its own Sub Directory and archiving sites: http://codex.wordpress.org/Giving_WordPress_Its_...
Archiving annual festival site
wordpress
I use to generate the ogp tags in themes I code but this commercial one is beyond my knowledge. The client want to share a page but any image option shows up. Instead of a <code> taxonomy-name.php </code> template file, this theme rely on a page templates, where user choose the category/taxonomy to display the gallery ...
If it is a <code> page </code> the global <code> post </code> object is already set when <code> wp_head </code> fires. But you have to get the data for this page with custom code. Pseudo code: <code> add_action ( 'wp_head', 'wpse_58539_get_ogp' ); function wpse_58539_get_ogp() { if ( ! is_page_template( 'your-template-...
Generating the ogp tags in theme
wordpress
I have implemented a Custom menu item in my wordpress dashboard using the following command in the functions.php <code> function create_menu() { $settings_page = add_menu_page('Edit_Post_69', 'Edit_Post_69', 'add_users', '/post.php?post=69&amp;action=edit', '', get_stylesheet_directory_uri() . '/editicon.png', 2); } </...
The probability is high that no hook will exist for that... But it can be solved with jQuery: <code> add_action( 'admin_head-post.php', 'wpse_58567_highlight_menu_item' ); function wpse_58567_highlight_menu_item() { global $post; if( 69 != $post-&gt;ID ) return; ?&gt; &lt;script type="text/javascript"&gt; jQuery(docume...
Add highlighting to new Admin Dashboard Menu Item
wordpress
From within a WordPress plugin, is there any way to get the name and email of the current user, when s/he is not logged in, but has recently submitted a comment, and specified name and email in the comment reply form? Or is the name &amp; email only available during the HTTP request in which [the comment posted by the ...
An unregistered user's name and email are available in cookies, once s/he has left a comment. The cookies are named like: <code> comment_author_3e6aea64ec43ed661a5dee3433f1e8bc comment_author_email_3e6aea64ec43ed661a5dee3433f1e8bc </code> You can retrieve them like so: <code> sanitize_comment_cookies(); wp_get_current_...
Get name and email of current unregistered user, who has recently submitted name and email in comment form?
wordpress
As per this question over on DBA.SE, I'm having quite a few issues with database optimisation. I'm just wondering if removing/disabling revisions will positively impact my database usage? We don't seem to use them as often as I was expecting. Currently I've got it set so that each post can have up to 3 revisions. If re...
Michael Adams, Quantum Bug Creator at Automattic once said : "Revisions are stored in the posts table. I don't yet know what kind of impact that will have on post queries. We're going to turn the switch to "on" on WordPress.com sometime soonish and we'll have a better idea about what kind of damage, if any, it does." A...
Will removing revisions positively impact database performance?
wordpress
It is possible send email for deleting account on wordpress?? Like this: http://i.stack.imgur.com/Lt6Ks.png Ok after click send email to user with ex text: "your account has been deleted" ??
Yes. The full answer is here in the codex: http://codex.wordpress.org/Plugin_API/Action_Reference/delete_user So I won't repost its code. <code> function my_delete_user($user_id) { global $wpdb; $email = $wpdb-&gt;get_var("SELECT user_email FROM $wpdb-&gt;users WHERE ID = '" . $user_id . "' LIMIT 1"); $headers = 'From:...
Send Email to Users after Deleting Account
wordpress
I'd like to create a custom dashboard widget that contains the search box from the posts edit screen. I know how to create the dashboard widget and how to display it, but I don't know how can I place the search box.
The following will do, although it redirects to the Posts listing page <code> /wp-admin/edit.php </code> ... Also included, search boxes for Pages and CPTs. Code <code> /** * PLEASE NOTE THAT THE FOLLOWING CODE DOESN'T HAVE ANY SANITIZATION or NONCE methods */ add_action('wp_dashboard_setup', 'wpse_58520_dashboard_sear...
Custom dashboard widget search box
wordpress
I'm building a city portal/ social business directory with buddypress and wordpress. All business listings are stored as a custom post type called 'business'. I'm using the following code to show the activity related to business listings in the activity stream <code> function bbg_record_my_custom_post_type_comments( $p...
You can filter on the action before it is saved by using add_filter on 'bp_blogs_activity_new_comment_action' as shown in bp-blogs-functions.php -> bp_blogs_record_comment() Or you can filter before the action is displayed by using add_filter on 'bp_get_activity_action' Probably better to do the former because you can ...
How to show customized activity for custom post types in buddypress activity loop?
wordpress
I want to have a related box to show up - but only if a related post is inside the div. If theres no post the whole "related_box" div should be not shown. Any idea? Here's the code so far. <code> &lt;div id="related_box" class="related"&gt; &lt;div class="movie_header"&gt; &lt;div id="featured"&gt;&lt;h2&gt;Related&lt;...
move the div section from the start to after the <code> if(have_posts()) { </code> line, and move the corresponding closing divs to just before the closing bracket <code> } </code> of this if statement; full code: <code> &lt;?php global $post; $terms = get_the_terms( $post-&gt;ID , 'movies', 'string'); $do_not_duplicat...
show div only if have a related post inside
wordpress
At the moment I'm trying to figure out why this snippet is not working basically I want to display a div id for different categories. I'm using the following. <code> &lt;?php if (in_category( array('6,14,15,13') )) { ?&gt; &lt;div id="eatheader"&gt; &lt;?php } elseif (in_category( array('7,11,12,10,9') )) { ?&gt; &lt;d...
The unnecessary semi-colon is probably causing the error. <code> &lt;?php } else { ;?&gt; </code> should be <code> &lt;?php } else { ?&gt; </code> . Try this: <code> &lt;?php if (in_category( array(6,14,15,13) )) { ?&gt; &lt;div id="eatheader"&gt; &lt;?php } elseif (in_category( array(7,11,12,10,9) )) { ?&gt; &lt;div i...
Different Category Headers using in_category and elseif
wordpress
In a plugin i developed i created metaboxes in the new/update post page in the admin area that save data into custom fields. In order to prevent confusion or any kind of issues i created those custom fields hidden by adding "_"(underscore) to the beginning of it. Now i realize that other plugins will not recognize thos...
Prefixing custom fields with an underscore only results in the keys being hidden from the default custom fields UI: There is nothing preventing plugins or theme code from otherwise querying these keys and their values.
Plugins won't recognize my plugin's hidden custom fields
wordpress
How do I remove the page listing menu in the header? I would like just the choosen header picture to show up without a listing of all of the pages on the site listed underneath. Also at the very top or the page it displays the domain and title above the header. What is the best way to eliminate that and just have the h...
there is a simple fix and that is removing line 103 in the themes header.php file but next time you update the theme it will return so to make you change permanent and still enjoy the updates first Create a child theme and then overwrite the header.php file in your child theme. its sound hard but its really not: First ...
How do I remove the page listing menu in the header in the Twenty Ten Theme?
wordpress
I am using this code here: <code> &lt;?php $trim_length = 25; //desired length of text to display $custom_field = 'my-custom-field-name'; $value = get_post_meta($post-&gt;ID, $custom_field, true); if ($value) { echo rtrim(substr($value,0,$trim_length)); } ?&gt; </code> It works - but I would like to have a "(...)" at t...
building on keatch's answer you only need to trim if its longer the 25 chars so: <code> $trim_length = 25; //desired length of text to display $custom_field = 'my-custom-field-name'; $value = get_post_meta($post-&gt;ID, $custom_field, true); if ($value) { if (strlen($value) &gt; $trim_length) $value = rtrim(substr($val...
trim custom field text value and show (...)
wordpress
I created a WordPress page template to build a customised XML feed for certain WordPress posts on my site. Specifically, the page template renders XML and only includes certain custom post types and only if these posts contain specific meta data. I'm using the data to feed WordPress content to an iOS application. It se...
Not sure how dramatic this'll be, but it should improve nontheless: <code> &lt;?php /** * You can try forcibly splitting the query (grabbing IDs *then* all fields) * Works well for large post results. (available WP 3.4+) */ add_filter( 'split_the_query', '__return_true' ); $posts = get_posts( array( 'post_type' =&gt; '...
How can I improve the performance of this query_posts loop?
wordpress
I have wordpress installed in the /home directory on my server, so it was set up that you would have to go to www.mywordpress.com/home to see my wordpress and just going to www.mywordpress.com would take you to a different homepage. Well, I went into my setting and change the Site Url so to www.mywordpress.com so that ...
If you have put the code in your header.php is the full URL to the Favicon correct? Also check in another browser as Favicons can be heavily cached (so check another machine) I'm assuming the non / page (without home) has the favicon code present on it as well? What is URL?
favicon now showing up
wordpress
I am trying to hack the default categories widget from wordpress. I have the categories displaying the way I want but I am having trouble editing the output. The widget shows the number of posts in each post which is what I want, but it also displays the number in parenthesis. I don't want that. I know how to get rid o...
<code> wp_list_categories </code> echoes output by default, your <code> str_replace </code> isn't working because nothing was assigned to <code> $list </code> .
Customizing Default Categories Widget
wordpress
How can i get search results from two different blogs [ www.mysite.com and www.blog.mysite.com ] using a single search form.
It depends on the setup; if they are setup as multisite, check this plugin: Multisite Global Search If that doesn't work, I'd try custom Google search. They should allow you to search on both sites.
How to search in two different wordpress blogs by using a single searchform?
wordpress
I have static front-page and separate page <code> /news/ </code> as the Posts page. I would like to have the single-post URLs like this: <code> www.example.com/news/categoryname/subcategory/postname/ </code> and for the category archives: <code> www.example.com/news/categoryname/ </code> What I've tried already: If I a...
I returned to this problem recently and I've found the solution finally! It may or may not work for you - there are two possible cases: If some posts on your site are placed under parent categories and some - in subcategories (child categories), or the categories have different nesting levels (some parent categories ha...
Including category-base in a post permalink results in 404
wordpress
I would like to remove the visual editor from one specific page because if I edit this one page in Visual mode, it breaks the code. I want to make sure the client doesn't have this option on the particular page. However, I don't want to remove the html editor. This line of code removes the visual editor and the html ed...
In your code, calling the action <code> admin_init </code> makes <code> is_admin() </code> unnecessary. And, if not mistaken, <code> is_page() </code> is meant to be used in the front-end... But the solution is the following (based on stackexchange-url ("this Answer")): <code> add_filter( 'user_can_richedit', 'wpse_585...
Disable visual editor on one specific page
wordpress
What code is required to put in <code> functions.php </code> in order to make the theme translation ready? The TwentyEleven theme has only following line: <code> load_theme_textdomain( 'twentyeleven', get_template_directory() . '/languages' ); </code> But in many tutorials they have mentioned to add following: <code> l...
The second part is not required, it just loads a PHP file with language specific functions. Examples In some countries/regions/religions it is not allowed to use capital letters in a word for anything else than the name of some god. In these cases you probably want to remove the Wordpress to WordPress filter . Some lan...
What is the purpose of an extra file for translation?
wordpress
i have a "Default Page Generator" on theme activation i have created... in that file i set 'menu_order' for each page. i want to exclude pages with menu order bigger then 50 from the default wp_list_pages menu Is there a way to check for / retrieve 'menu_order' of each page? and if there is can you think of a way to in...
Declare the following function in your functions.php <code> function wpse58346_wp_list_pages( $pages, $r ) { foreach( $pages as $key =&gt; $page ) { if ( 50 &lt; $page-&gt;menu_order ) unset($pages[$key]); } return $pages; } </code> Now before calling <code> wp_list_pages() </code> apply a filter as follows <code> add_...
Exclude pages by menu order
wordpress
I have posted a stackexchange-url ("question") on StackOverflow (sorry for the cross link) and while I'm striving to find a solution to this, I stumbled across this warning : Warning: urlencode() expects parameter 1 to be string, array given in /var/www/.../httpdocs/wp-includes/formatting.php on line 3192 And doing a b...
I'm not sure exactly what's happening, but I can guess based on a few context clues. That particular function is <code> parse_tax_query </code> . It appears to be checking if the taxonomy is hierarchical, I assume it's expecting a string that could possibly be a parent/child path of terms, so it uses basename to get th...
Warning: urlencode() expects parameter 1 to be string, array given
wordpress
I'm looking for a way to remove the rows with the title, date and other stuff that's shown on the manage posts/pages screen (highlighted with red in the image below). I know that I could easily hide it with css, but I'm wondering if it's possible to do it without css and hacking core files.
I'm gonna post the CSS anyway because this is the best way to hide it. <code> table.pages thead, table.pages tfoot { display:none; } </code> I didn't find any useful hooks in the source that would allow to pull the actual HTML for the table header and footer out.
Remove rows in the manage post/page view
wordpress
So I have made some custom textareas on my frontpage template. This works fine and I can safe content and so on... But I am experiencing some issues. When I click "Upload/Insert" I can work with the dialogue - but when I type insert the dialogue closes but no image is inserted into the textarea... The other issue is wi...
Not saying it's not possible, but wp_editor is not designed to be used in a meta box (when tinyMCE, which is on by default, is activated). Here's the trac ticket where some of the issues are discussed. You can however, use the actions <code> edit_page_form </code> or <code> edit_form_advanced </code> to add your editor...
wp_editor on custom meta textarea field - images and html fails
wordpress
One of the most common security best practices these days seems to be moving <code> wp-config.php </code> one directory higher than the vhost's document root . I've never really found a good explanation for that, but I'm assuming it's to minimize the risk of a malicious or infected script within the webroot from readin...
Short answer: yes The answer to this question is an unequivocal yes , and to say otherwise is completely irresponsible . Long answer: a real-world example Allow me to provide a very real example, from my very real server, where moving <code> wp-config.php </code> outside the web root specifically prevented its contents...
Is moving wp-config outside the web root really beneficial?
wordpress
I am creating a shortcode for a client site that should display an image and a saying (mainly at the bottom of the page, but basically wherever the client wants to insert said image/saying). The image would remain the same, and there will be a "standard saying", but the client would like the potential to change the say...
The second parameter of your shortcode function is the content. So rewrite the function: <code> function shortcode_call_to_action( $attributes = NULL, $content = '' ) { $stylesheetdir = get_bloginfo('stylesheet_directory'); if ( '' === $content ) { // use a default text if there is no content $content = 'default text';...
Shortcode with custom content attribute?
wordpress
All the comments on my website are anonymous and without registration. To post a comment you have to fill the fields name (not obligatorily) and the text of your comment (obligatorily). I have the problem with the avatars. All of them are generated the same. What should I do to make them different?
There are two ways to customize the default avatar: Add a new default avatar to Settings/Discussion . Change the output of <code> get_avatar() </code> . Let’s start with the first option; this processes slightly faster. Add a new default avatar to Settings/Discussion There is a filter <code> 'avatar_defaults' </code> ....
What should I do to make generated avatars different for anonymous comments?
wordpress
So I have this Wordpress blog at ilovetheupperwestside.com . It uses the Aggregate Theme from Elegant Themes. I moved it from a temporary location to the current URL. This action broke some things, but thanks to a plugin called "Velvet Blues Update URLs" and a (serialization safe) database search &amp; replace script n...
I fixed it by editing "custom_functions.php" within my theme, it was a bug that occurs when updating some Elegant themes. Instructions here: http://www.agentwp.com/fix-thumbnails-not-working-in-a-wordpress-theme-from-elegant-themes
Why is my Wordpress install using full server directory paths for media URLs?
wordpress
I want to make a website with wordpress engine but with some features. One website has 3 template and every template is active because I want to make 1 website that has 3 sub categories such us blog, portfolio, and photo gallery but with different templates and fitur in every sub-category. Anyone knows how to do that, ...
Yes it is possible to create templates for different categories and tags for posts you can also use a plugin like this http://wordpress.org/extend/plugins/custom-post-background/ If you look at (for example) http://woothemes.com - then their free theme it already has a blog, portfolio and photo gallery templates for yo...
How to make website with many template that active
wordpress
Some themes ask you not to edit the style.css file, instead use custom.css file. If you write code on custom.css, it will overwrite the same element style in style.css. I think this is done in order to prevent the loss of user styles on theme update, is it so? How this works? Do they already include custom.css file in ...
I usually add this piece of code if I want to add another css file <code> &lt;link rel="stylesheet" href="&lt;?php bloginfo('template_url'); ?&gt;/css/my_custom_css.css" type="text/css" media="screen" /&gt; </code> I believe the theme makers want to retain as much as possible of the theme's layout design. So a custom c...
How to add custom css file in theme?
wordpress
Genesis framework applies filters to the wp_nav_menu(). What I want to do is 2 things. 1 change the menu class via a filter 2 add a menu id via a filter Here is the function I am trying to add a filter to. <code> add_action( 'genesis_after_header', 'genesis_do_nav' ); /** * Echoes the "Primary Navigation" menu. * * The...
This new updated version of Evan's Code works with Genesis 1.9 and fixes the bug of displaying all navigation items. <code> /* * Add classes to Genesis Navigation * Tested with Genesis 1.9 (Beta) * 29.12.2012 */ add_filter( 'genesis_do_nav', 'override_do_nav', 10, 3 ); function override_do_nav($nav_output, $nav, $args)...
Using a filter to modify Genesis wp_nav_menu
wordpress
I'm trying to use the <code> get_image_tag() </code> function to alter the html output of an image, like so : <code> add_filter('get_image_tag', 'kh_image_attachment', 10, 5); function kh_image_attachment($html, $id, $alt, $title, $align) { $html = '&lt;img src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAA...
Solution: I needed to use the <code> wp_get_attachment_image_src </code> function. <code> add_filter('get_image_tag', 'kh_image_attachment', 10, 5); function kh_image_attachment($html, $id, $alt, $title, $align) { $image_source = wp_get_attachment_image_src( $id, 'full' ); $html = '&lt;img src="data:image/gif;base64,R0...
get_image_tag() html output : empty src attribute
wordpress
I'm normally quite the techie (look at my SF account!) but it turns out I know nothing about Wordpress and in doing so have sabotaged my wife's blog. As a family we have a hosting package through Namecheap who also manage my domains, I'm fine with the whole DNS thing. They provide web hosting via /public_html and using...
If you still have access to your wife's blog, I would recommend: Running a regular WordPress export of the content Downloading the entire <code> /wp-content </code> directory over FTP These are the two most important parts of the site - the content and the uploads. From this, you should be able to recreate the site on ...
Recover from failed multisite conversion
wordpress
I'm using PHP Widget which allows PHP code to execute from a widget. I tried using this code to execute do_shortcode but it's not rendering <code> &lt;?php $lat = get_field('woo_maps_lat'); $long = get_field('woo_maps_long'); echo do_shortcode('[forecast location="' . $lat .','.$long. '" measurement='C']'); ?&gt; </cod...
The problem was the double quotes which are needed in normal shortcode usage in posts and pages for some reason when using do_shortcode the double quotes in the attributes where breaking the function. Working code below <code> &lt;div&gt; &lt;?php $lat = get_field('woo_maps_lat'); $long = get_field('woo_maps_long'); ec...
PHP Widget and do_shortcode
wordpress
I'm having a weird issue while setting up a site. It almost seems as though the /blog/ url is reserved or already in use, only it isn't as far as I can tell. I setup a new page called 'Blog' and set the permalink to '/blog/'. Then under 'Settings' => 'Reading' I set the Posts page to be 'Blog'. Then I went one step fur...
Change the filename from <code> tpl-blog.php </code> to <code> page-blog.php </code> , see if that fixes it.
Where is the /blog/ url set from?
wordpress
I have seen script and style handles written in two different ways in <code> wp_register_script </code> and <code> wp_enqueue_script </code> (the same applies to <code> wp_register_style </code> and <code> wp_enqueue_style </code> ): <code> wp_register_script( 'jquery-someplugin', $location ); </code> <code> wp_registe...
Use hyphens only. Take a look at <code> wp-includes/script-loader.php </code> : <code> $scripts-&gt;add( 'scriptaculous-sound', '/wp-in $scripts-&gt;add( 'scriptaculous-controls', '/wp $scripts-&gt;add( 'scriptaculous', '', array('sc // not used in core, replaced by Jcrop.js $scripts-&gt;add( 'cropper', '/wp-includes/j...
Hyphens vs. periods in the script slug in wp_register_script?
wordpress
How do I disable adding of new posts of a particular custom post type? Found this code in Log Deprecated Notices plugin: <code> $screen = get_current_screen(); if ( self::pt == $screen-&gt;id &amp;&amp; ( $screen-&gt;action == 'add' || $_GET['action'] == 'edit' ) ) wp_die( __( 'Invalid post type.', 'log-deprecated' ) )...
<code> add_action( 'load-post-new.php', 'wpse_58290_disable_new_post' ); function wpse_58290_disable_new_post() { if ( get_current_screen()-&gt;post_type == 'my_post_type' ) wp_die( "You ain't allowed to do that!" ); } </code> Note that you'll also need to hide the UI elements, such as in the menu, and the "Add New" bu...
Disable adding of new post (custom post type)
wordpress
Hi want to ask if anyone can share an idea on how Mashable registration works? Basically the only option you have to register to their site is by Facebook or Twitter, after you login to one of them it automatically create a wp_user. No more Wordpress login/Regs needed. I know many plugins like Simple Facebook/Twitter/G...
Mashable Follow is custom built for Mashable.com, so you won't find a plugin that brings that level of integration to your WordPress site. That said, there are two that may suit your purpose: Social : Integrates your WordPress site with social networking sites Twitter and Facebook, thereby offering a whole lot of featu...
Create Mashable Follow-like Facebook, Twitter login/connect?
wordpress
Probly easy question but just cant seem to find whats wrong. I cant build a query based on a search when i use ' ' but not when i use a alrdy declared variable. This works <code> $query2 = new WP_Query( 's='motorkap met' ); while( $query2-&gt;have_posts() ) { $query2-&gt;the_post(); echo the_title();?&gt; &lt;/br&gt; &...
Assuming <code> removeCommonWords() </code> returns a string, you can do the following: <code> $zoekterm = removeCommonWords('motorkap met'); $query2 = new WP_Query( array( 's' =&gt; $zoekterm ) ); while( $query2-&gt;have_posts() ) { $query2-&gt;the_post(); echo the_title() . '&lt;/br&gt; '; } </code> Sometimes the arr...
How go give $value to wp_query
wordpress
I want to have to display related post within a post based on the post title. So for example I have a post named "France gas prices". First it displays all the post info but then under the post I want to have search results displayed using the "france gas prices" value. Now I could use this. (example search on specific...
<code> WP_Query </code> accepts a search parameter , 's'. Hence, you can just do this: <code> &lt;?php $related_posts = new WP_Query( 's=' . the_title_attribute( '', '', 0 ) ); if( $related_posts-&gt;have_posts() ) : while( $related_posts-&gt;have_posts() ) : $related_posts-&gt;the_post(); // STUFF endwhile; endif; wp_...
Use wordpress search to display results within a post
wordpress
I'm attempting to debug a unit test for a WordPress plugin. The unit test uses wordpress-test (and PHPUnit). However, wordpress-test : calls <code> system(php ...) </code> the new external PHP process attempts to connect to the same debugger , but the debugger is already busy so both PHP processes hang. — How can I pre...
Now I've found a solution [to issue 2 above]: I prefixed the external PHP command with: <code> XDEBUG_CONFIG="remote_enable=Off" </code> and then it didn't attempt to connect to the debugger. So, in <code> wordpress-tests/init.php </code> I changed from: <code> system( WP_PHP_BINARY . ' ' . escapeshellarg( dirname( __F...
How to debug a unit test for a WordPress plugin, which uses wordpress-test?
wordpress