question stringlengths 0 34.8k | answer stringlengths 0 28.3k | title stringlengths 7 150 | forum_tag stringclasses 12
values |
|---|---|---|---|
I currently have the Modern Style Theme installed. If you click on an image on my page, it links directly to the highest resolution version of that image. ( Example post with one image ) I would rather like it to link to an "attachment page", where the description of the image is also showen. How can I do that? | When you insert a new media, you get to choose the Link URL . Under the field, there are 3 buttons, simply click Attachment Post URL to link to it. | How can I make image linking to attachment page (rather than a direct link)? | wordpress |
I have a custom search page via which I select: <code> One or ALL categories One or ALL tags One or ALL authors A search string or no search string </code> On the results page, wp_query works when I have selected values. But how do I instruct to set some param as ALL? How do I set "search ALL categories" for example? M... | Assuming you have variables to hold your custom values for each: <code> $category </code> <code> $tag </code> <code> $author </code> <code> $search </code> Then just create an arguments array, and add keys to it conditionally: <code> $custom_query_args = array( // Set any default args here // NOTE: This is where you'd ... | wp_query with parameters | wordpress |
I need to see if an option, and if does, get the value. If not, I need to add it. The Codex provides: <code> <?php $option_name = 'myhack_extraction_length' ; $new_value = '255' ; if ( get_option( $option_name ) != $new_value ) { update_option( $option_name, $new_value ); } else { $deprecated = ' '; $autoload = 'no'... | The logic on the IF THEN ELSE does seem a bit wonky. If I'm reading it correctly... The call to get_option( $option_name ) will return FALSE if the option does not exist or if it has no value. So the IF would be executed: when the option doesn't exist and $new_value != FALSE the option has no value and $new_value != FA... | Add Option if Not Exists | wordpress |
<code> add_action( 'customize_register', 'boilerplate_customize_register' ); function boilerplate_customize_register($wp_customize) { $wp_customize->add_section( 'themename_color_scheme', array( 'title' => __( 'Color Scheme (sect!on name)', 'themename' ), 'description' => "This changes color scheme", 'priority... | The theme customiser will take the upload and put it in wp-content, but the folder or specific place is irrelevant. If you find yourself using it, you've made a mistake and your code has gone horribly wrong. To be specific, your option is not referring to an image you uploaded, it is referring to an Attachment, specifi... | Where does the uploaded image go? | wordpress |
I am currently developing a new WordPress theme employed on the basis of twitters bootstrap build. To use the menu Custom Navbar, I've followed the instructions of goodandorgreat. https://gist.github.com/1597994 My problem now is that menu items with submenus are also clickable. That should not be so. What could I do h... | I am admittedly out on a limb here because to test this I'd have to install your code and create some menus to test it with, but... Look in the <code> Bootstrap_Walker_Nav_Menu </code> code. Find this: <code> $item_output .= '<a'. $attributes .'>'; $item_output .= $args->link_before . apply_filters( 'the_title... | Bootstrap menu - make menu entries with submenu not clickable | wordpress |
I'm trying to create a child theme. I copied the files from my twenty eleven theme into my twenty eleven child theme folder, and now the webpage displays blank page. my dashboard settings changed after I created the child theme that is why I decided to copy all files from main theme to child theme folder. what should I... | If you just copy all the files it will never work, the reason being that the functions.php file is included from both parent theme & child theme resulting in re-defining of a few functions(which is a php error) Don't copy the functions.php file, copy all the other files & modify the few lines at the top of styl... | child theme - moved files from twentyeleven theme to child them, now not working | wordpress |
I have an API link ( <code> $content </code> bellow), and I need to display the content fetched from this link in the dashboard. I don't have slightest idea how to do this. <code> if( !class_exists( 'DevMind_DashboardWidget') ) { class DevMind_DashboardWidget { function devmind_dashboard_widget() { // External Iframe W... | First, that <code> echo '<script src="//www.gmodules... </code> seems completely unrelated to the question, isn't it? Second, that API is for a paid service without a public API, so we cannot answer for their "api answer". Ask their support. What you are looking for is <code> wp_remote_get </code> . Normally, the re... | How to import data from another website using an API link? | wordpress |
Ever come across a plugin that is using the <code> manage_options </code> capability for a page that... really doesn't need to be? Well, I've come across just that. This may be more of a general question about hooking into <code> add_submenu_page </code> , so not just specific to my use-case. I looked at <code> add_das... | Hook into <code> admin_head </code> , the last action before the menu is rendered, and change the global <code> $menu </code> : <code> add_action( 'admin_head', 'wpse_71303_change_menu_cap' ); /** * Change the capability to access an admin menu item. * * @wp-hook admin_head * @return void */ function wpse_71303_change_... | Hooking into add_submenu_page | wordpress |
I have one page with custom posts. They are shown in one page with a list, you can choose one page and when you get to that page I need to show subpages of that page. Here is so far ive made it, its the first page with the custom posts: <code> <select name="select_page" id="select_page" class="select_page" data-mini... | The problem is here <code> $subpages = get_pages( array( 'child_of' => $pageId, 'sort_order' => 'asc', 'sort_column' => 'menu_order') ); </code> 'child_of' parameter also queries for the grandchildren along with children. Use the 'parent' parameter instead which will only query for the direct children. Once th... | Getting subpage of subpage - Custom posts | wordpress |
I understand that using add_filter() or remove_filter() directly within a themes' functions.php would make the changes global across the theme unless you override them elsewhere. But believe this is a result of WordPress initialization. <code> add_filter( $tag, $function_to_add, $priority, $accepted_args ); </code> How... | It is always global. <code> add_filter() </code> and <code> add_action() </code> are just wrapper for the global variable <code> $wp_filter </code> . So it doesn’t matter where the function is called. The same is true for <code> apply_filters() </code> , <code> apply_filters_ref_array() </code> , <code> do_action_ref_a... | What is the scope and persistence of add_filter() and remove_filter()? | wordpress |
I have a shortcode that is built using a Thickbox form with various inputs that return the values. This works fine. However, I would like the existing values (if present) to re-populate the form if the user opens it again. Here is an example of my shortcode: <code> [schema type="person" name="Andrew Norcross" descripti... | Try something like this... <code> var code = $('div#wp-content-editor-container textarea').text().match(/\[(schema.*)\]/); code = '<' + code[1] + '>'; alert($(code).attr('description')); </code> | include shortcode values in Thickbox form | wordpress |
I am creating a magazine style wordpress site. We have multiple issues which will be parent categories and these will have around 3-5 sub categories. Every quarter we will create a new issue with new subcategories. E.g. Issue 7 -> news journal worldview letters etc... I have a page which lists all of the parent categor... | I think the simplest way would be to just use the category archives that WordPress already generates. Change the category base in permalink settings to <code> issues </code> so you have nice URLs, then in the category template , check if you're viewing a top level or child category, and display the appropriate markup: ... | Parent Category link to its sub categories on different page | wordpress |
Having some troubles with a PHP script I am trying to build. I need to access the a file which is located in the root folder of my Wordpress install: wordpress-root/live-config.php Problem is, my script file is located inside the theme's root folder, and I'm trying to access the root folder when defining a constant. My... | I guess you're talking about a site specific <code> wp-config.php </code> file that resides in your themes folder. At the point where you're loading the <code> wp-config.php </code> file, WP isn't fully loaded, so you ain't got any constants or filesystem API or other basic API functions available. Here's how I approac... | Accessing site's root from themes folder | wordpress |
I am making system where I am delegating a lot of functionality to the front end of a system using Wordpress. I have listed all the roles (most of the custom) and need to ability for a logged in user to edit the name of the role or delete it. I cant find any normal WP functions to do this, or plugins that allow the sim... | There's a whole host of functions specifically for this purpose; http://codex.wordpress.org/Function_Reference#User_and_Author_Functions Of particular interest (but not limited to) are, <code> add_cap add_role get_role map_meta_cap remove_cap remove_role </code> As well as numerous other user related functions that wil... | Programmatically changing role information; editing role name and deleting | wordpress |
I'm trying to make a php script which, given a post id, returns post content. I'm not the one who writes articles, I'm just operating on a wp site. Post content is for an app of mine which has to parse it. My script is very simple: <code> <?php require_once("wp-load.php"); if(isset($_GET['id'])){ $post_id = $_GET['i... | The <code> [caption] </code> part shows up because one of your authors/editors added a caption to the image when it was inserted into the post. You will have this problem not only with captions but with any other shortcodes that your authors/editors use. And you should be aware that WordPress includes several in its Co... | Can't understand why sometimes a [caption] field appears | wordpress |
I'm adding a custom column named Excerpt with Codepress Admin Columns, and would like to know specifically when the Excerpt has not been filled out. Instead WordPress shows post content automatically, if the excerpt is missing. This is also testable by switching on the "Excerpt View" from post list screen. Implementing... | Just illustrating this in full effect here with the filters and functions for both the adding of custom column and testing for excerpt existence. Note, I've purposely ripped the guts out of <code> has_excerpt </code> to show you in effect what is occurring under the hood. You can use <code> !has_excerpt </code> in its ... | How to disable automatic excerpt generation *in admin*? | wordpress |
Just wondering what the best way to get the top-most level category (grandparent) of a given category assuming it has one? Example structure: Operating Systems - Mac - - Mountain Lion - Windows - - Windows XP I want to be able to somehow get the ID of the "Operating Systems" category from within the Windows XP category... | You could write a simple function to do this each time you need to. Here's an example I found on this website . <code> function pa_category_top_parent_id( $catid ) { while( $catid ) { $cat = get_category( $catid ); // get the object for the catid $catid = $cat->category_parent; // assign parent ID (if exists) to $ca... | How to get grandparent of a given category | wordpress |
Hopefully a simple answer to this. Using the wp custom header feature, the media upload screen shows an extra field: "set as header". I'm trying to make this text bigger as it can easily be missed. Firebug says it has a class of "a.wp-set-header". I can change the font size within firebug and it works, but adding this ... | Its likely that you're not enqueing your CSS file to be used in the admin area, however you did not say. Anyway, this is what you can do... Place the following into your functions.php file: <code> add_action( 'admin_print_styles', 'my_admin_css' ); add_action( 'wp_enqueue_scripts', 'my_admin_css' ); function my_admin_c... | Custom Admin CSS styles to style media uploader? | wordpress |
I m trying to share my web site contents for other web sites using by external loop file or rss file. when i asked some questions about <code> wp_remote_get </code> function ; @Serkan suggest to me , using <code> fecth_feed </code> methot / function etc. (check the stackexchange-url ("question here").)= I really confus... | Neither are high performance, and they do different things. <code> fetch_feed </code> is for grabbing feeds RSS feeds etc, <code> wp_remote_get </code> is for grabbing arbitrary items. Neither are fast, and the performance difference between each is negligible or irrelevant, but technically <code> fetch_feed </code> is... | wp_remote_get vs. fetch_feed ? which is the better for performance? | wordpress |
Here is my wordpress theme to check out(its not completely finished): http://benlevywebdesign.com/wordpress/ This is my first time working with php/wordpress and making themes so keep that in mind. I have an index.php, css, and a 960.css file and don't know about the other files that you can include. In my theme I woul... | Depending on which 'types' you need, you might be looking for the Post Format functionality. It allows you to set posts as standard, quotes, galleries, etc (sort of like Tumblr). To activate it, simply toss this into your theme (probably functions.php): <code> add_theme_support( 'post-formats', array( 'aside', 'gallery... | I would like to have different styles for my posts based on the content of each post | wordpress |
I would like to know what is the best way to create a different template for parent and children categories and/or taxonomies. Example: I have a taxonomy called region, which I want to divide in countries, and cities inside countries. So, I will have a parent taxonomy term called Italy, and it's children taxonomy terms... | I suggest creating 3 files 1) regiontemplate-country.php 2) regiontemplate-city.php These 2 will contain the templates for country & city, then 3) taxonomy-region.php In this file, add the code to load the appropriate template <code> <?php $term = get_term_by('slug', get_query_var('term'), 'region'); if((int)$te... | Different templates for parent and children categories/taxonomies | wordpress |
I used the Advanced Custom Fields plugin to add a custom field to my taxonomy. That custom field is an image which is associated with the term. Now I have a page where I display a list of all terms (for example, car manufacturers): <code> $terms = get_terms("manufacturer_tax", array( 'hide_empty' => 0 )); $count = c... | OK had a go at this myself, I didn't realise ACF was able to add fields to taxonomies which is really handy so I wanted to figure it out too. <code> <?php $libargs=array( 'hide_empty' => 0, 'parent' => 0, 'taxonomy' => 'library_categories'); $libcats=get_categories($libargs); foreach($libcats as $lc){ $term... | Advanced custom fields - taxonomy terms images | wordpress |
I protected a page with password. I’d like to add a short error message when the inserted password is incorrect. How can I do this? I add this code to show and customize the form on my page. My <code> functions.php </code> <code> add_filter( 'the_password_form', 'custom_password_form' ); function custom_password_form()... | The latest entered password is stored as a secure hash in a cookie named <code> 'wp-postpass_' . COOKIEHASH </code> . When the password form is called, that cookie has been validated already by WordPress. So you just have to check if that cookie exists : If it does and the password form is displayed, the password was w... | Add error message on password protected page | wordpress |
Is it possible to delete post/page revisions from the database when a post/page is published? 11/05/12 Answer: See the plugin below by bueltge I want to do this on a site with 5,000 posts and 125,000 comments; it's on a VPS and can handle the wp_posts table size - before I deleted all revisions, the table was 1.5 gigs ... | I think a small plugin with the hook 'publish_posts' is enough. But I dont know about a core function to delete revisions and I use a query with WP functions. The source is untested, written only for this post. <code> <?php /** * Plugin Name: WPSE71248 Delete Revisions on Publish Posts * Plugin URI: stackexchange-ur... | Delete post revisions on post publish | wordpress |
I have modified an old Stackoverflow inspired badge system script to work with the latest Wordpress version. You can view the code here (and please feel free to use it if you wish): http://pastebin.com/zA4zGnKZ It has a condition system that detects <code> Post tags </code> , <code> Post count </code> and <code> Commen... | On line 704 it mentions something about "User_ID => 5". Not sure, but this might have something to do with your problem? <code> // debug shit $args = array('user_ID' => 5); rhb_check_user_badges( $args ); </code> | Bug in Stackoverflow styled badge system script | wordpress |
My site has a user profile page. For some reason I would like to pull user profile data in my plugin. I know I can pull logged in user profile data using <code> get_currentuserinfo(); </code> . For example I would like to get displayed profile user id. Can anyone tell me how to pull it.? | If you're trying to get user data for the displayed profile, you can do it like so: <code> $thisauthor = get_userdata(intval($author)); </code> That'll return an object filled with everything you need. For instance, if you need the user ID, you can call it like so: <code> $thisauthor->ID </code> I use this extensive... | How to pull user/author profile data in a plugin? | wordpress |
I have tried many plugins to create a slideshow out of photos I have uploaded to my NextGen galleries. Specifically, I want this slideshow to incorporate photos from all of my galleries. However, so far, the plugins I have encountered only allow for the photos in the slideshow to come from one gallery (as specified by ... | If you look at the nextgen gallery slideshow widget you will find the option "select gallery" => "all images". | How do I create a NextGen slideshow to show all photos? | wordpress |
I have a custom post type of 'artworks' and a custom taxonomy of 'artists'. On page-artists.php I have created a custom list of all the artists and would like to link each artist's name to the first post associated with that term instead of going to the term's page. This is my current code: <code> <?php while ( have... | <code> // link artist name with first work by that artist $term_list .= '<li><a href="' . get_term_link( $term->slug, $term->taxonomy ) . '" title="' . sprintf(__('View all post filed under %s', 'my_localization_domain'), $term->name) . '">' . $termfirst . ' ' . $term->name . '</a></li&... | Taxonomy list links to first post in that term | wordpress |
WordPress apparently stores post format information outside of the <code> $post </code> object. During <code> publish_post </code> this isn't (usually) a problem because you can check on formats via <code> get_post_format( $post->ID ) </code> outside the loop. This doesn't appear to work during <code> xmlrpc_publish... | This is because of a variable mismatch. Your function accepts <code> $post_ID </code> , but you don't actually use it. You're instead trying to reference a global <code> $post </code> object and doing your post format check with <code> $post->ID </code> . With the XML-RPC request, this won't work. Rewrite your funct... | Checking post format during xmlrpc_publish_post | wordpress |
This is a problem I am having with qTranslate, but I suppose the solution is more of an instruction in how Wordpress hooks and filters work. Instead of using the qTranslate widget, I am using the hook <code> <?php echo qtrans_generateLanguageSelectCode('text');?> </code> to call the language chooser in my header ... | In my <code> header.php </code> , where I want qTranslate language chooser to live, I put this in: <code> <?php echo qtrans_SelectCode('code');?> </code> Then, I added this code to <code> functions.php </code> . It's a little redundant in that it repeats the built-in qTranslate options (image, text, dropdown) whi... | Adding a filter to qTranslate to change display of language chooser | wordpress |
So far I've narrowed down the execution trail to <code> index.php </code> -> <code> require('./wp-blog-header.php'); </code> -> <code> if ( !isset($wp_did_header) ) { require_once( dirname(__FILE__) . '/wp-load.php' ); </code> -> <code> if ( file_exists( ABSPATH . 'wp-config.php') ) { require_once( ABSPATH . 'wp-config... | Setting the <code> max_execution_time = 300 </code> inside my <code> php.ini </code> resolved it. | Wordpress wont startup | wordpress |
I keep running into an issue getting the file(s) added/switched to ajax so that the server ajax handler can deal with the rest. How can I get the $_FILES to be passed the same as with the default action (built into form elements)? Updated I was originally sending a mixed object, but modified it to use the FormData Obje... | I haven't tried but i think you need to add <code> FormData </code> object directly as <code> data </code> parameter. Something like this <code> var ajaxData = new FormData(); ajaxData.append( 'action', 'ajax_handler_import' ); ajaxData.append( '_ajax_nonce', importNonce ); // or maybe skip the nonce for now jQuery.eac... | How do I Upload/Import Form (Input) Files via. Ajax function? | wordpress |
Im storing my images on another server and Ive managed to change the urls in the database but I cant seem to change the featured image urls? I will not be adding any more images so I just want to change the url for all images. This is the sql I used for normal images <code> UPDATE wp_posts SET post_content = REPLACE (p... | The featured image is stored in the <code> *_postmeta </code> table under the <code> _thumbnail_id </code> key. In fact, chances are that you've got a lot of image/media urls in that table, which you haven't changed. The problem is that a number of things are stored in serialized arrays and changing them with SQL as ab... | Change featured image urls in database | wordpress |
In the .js script below, the ajaxPath reference breaks when the containing page is off the root directory of the site. Is there a workaround to make this path absolute? <code> jQuery(document).ready(function($){ initContentEditable(); var dir = ContentEditableSettings.content_editable_url; var ajaxPath = 'wp-admin/admi... | As long as your <code> wp-admin </code> directory is still at the root of your site, you can just add a forward slash ( <code> / </code> ) to the URI. Alterntaively, you can use <code> wp_localize_script() </code> to pass in your site's URL or, if you are using WordPress's AJAX functions, the <code> ajaxurl </code> JS ... | Convert this relative path to absolute | wordpress |
I have what used to be a child theme but I added to it to the point where its a theme on its own. I pulled out the Template line in the style.css and now I get the: This theme is broken. Template is missing. error. Why is this happening? | That error appears when the theme directory has no "index.php" file. For a full theme, an index.php file is required. | Why would changing a child theme to a normal theme pass a Template is missing. error | wordpress |
I've got a custom post type with a standard tag taxonomy added to it like so: <code> 'taxonomies' => array('post_tag') </code> . I've added some tags to some posts of this CPT which are display on the front-end with the template tag <code> the_tags() </code> and the links it generates have this format <code> http://... | This is a bug (one that I've encountered before) and could do with a ticket in trac (since I never took the time to submit one!) The trouble starts with requests that set multiple <code> is_* </code> query flags as true (specifically flags that represent objects, such as single posts, pages, and post type & term ar... | Undefined property: stdClass::$labels in general-template.php post_type_archive_title() | wordpress |
I've just implemented a new WP website, replacing an older hardcoded HTML site. I will be adding 301 redirects in the <code> .htaccess </code> file to point the old URIs to the new WP Permalinks. My questions is, as WP generates the <code> .htaccess </code> file initially (at least on my install it did) will WP overrit... | Generally speaking WordPress will update the .htaccess file any time you change the permalink structure. Many plugins will also update/modify the file as needed. But the default structure of the .htaccess file allows you to lay it out in such a way that WordPress will not overwrite your custom entries. WordPress will o... | Does WordPress Change the .htaccess File When Updating? | wordpress |
I am using the "Edit Author Slug" plugin to provide public profile pages on my site using the following structure: mysite.com/users/username . Now, I want to show a list of all users on mysite.com/users/ . But this returns a 404 because the "users" path is only a slug created by the plugin. Does WP provide the possibil... | Try creating a Page with the users slug, then using a custom Page Template to provide the functionality you want to display all the users. | Template for slug | wordpress |
I accidentally removed a bunch of plugin folders. I restored them all directly after, but since then my site is completely blank. Can't see anything, it's just white. I'm not sure what to do, but looking at a log file seems like a good start. Is there one? | There's not one if you didn't set one up. The codex has a good example of how to do this. <code> <?php @ini_set('log_errors','On'); @ini_set('display_errors','Off'); @ini_set('error_log','/home/example.com/logs/php_error.log'); /** * This will log all errors notices and warnings to a file called debug.log in * wp-co... | Does wordpress have an error log? | wordpress |
I've been playing with the wp custom header and background options. I like the way you can tile a small image for the background, and looking for a way to add that option to the custom header image as well. My theme has a div for the header and I've added the wp custom header like so: <code> <div class="header"> ... | You are putting an image into the style attribute - this is wrong. You only need the path, not a tag: <code> <div class="art-header" style="background-image:url('<?php header_image(); ?>'); background-repeat:repeat; height:<?php echo get_custom_header()->height; ?>px; width:<?php echo get_custom_he... | Custom header tiling? | wordpress |
Was wondering if anyone knew of a way to remove the query string from external Javascript sources, such as Google's jQuery. Thanks in advance for any help | Filter <code> 'script_loader_src' </code> , you get the source URL as first argument. Then run <code> remove_query_arg() </code> on this URL and return the shortened version. Sample code: <code> add_filter( 'script_loader_src', 'remove_script_version_parameter' ); function remove_script_version_parameter( $src ) { retu... | Remove Query String from Google jQuery | wordpress |
In a wordpress plugin, how can I duplicate/clone a single post? I would need to: 1) get a specific post 2) clear its ID property so that it's saved as a new post 3) save it. In the process, I would like to see all the meta info + taxonomy associations preserved. | Take a look at the 'Duplicate Post' plugin at http://wordpress.org/extend/plugins/duplicate-post/ | How do I duplicate a single post, with all its properties, and save it as a different post? | wordpress |
I'm doing an experiment and looking for a WordPress theme that utilizes the contenteditable html5 property to allow in context editing on the live website (for authenticated admin users). Are there any examples? | I don't know about a theme but i wrote this a while back as a "Prof of concept" which simply wraps the content inside an editable div and sends the data in an hidden textarea along with nonce: <code> if (!class_exists('contentEditable')){ /** * contentEditable class * @author Ohad Raz */ class contentEditable { public ... | Wordpress theme (or plugin) that uses Contenteditable property | wordpress |
interesting problem that I encountered, not sure if it's bug or not.. On a clean install using the twentyeleven theme I try changing the Permalink Settings to something different from the Deffault and every post starts giving Page Not Found 404. The Pagination and the top Nav Menu also stop working. What needs to be ch... | Check to make sure your .htaccess file (in the root) is writable by WordPress, if it isn't then you may need to manually set this up to get the permalinks working correctly. | Clean install - Changing permalinks in twentyeleven give 404 | wordpress |
I am using Advanced custom fields <code> acf_save_post </code> hook in one of my functions. In that function I use the <code> add_post_meta </code> function. Does this call <code> acf_save_post </code> again and cause an endless loop? http://www.advancedcustomfields.com/docs/functions/hooks-filters/#acf_save_post | <code> add_post_meta </code> doesn't call the same hook again but there are some other functions such as <code> wp_update_post </code> which call the hook again. In case it is going into infinite loop you'll have to call <code> remove_action </code> inside the function to not make it recursive | does acf_save_post cause endless loop? | wordpress |
I am using the following loop on <code> index.php </code> . The current viewed page would be one of the link in the loop. How to make sure it is marked as current? <code> <ul id="questions" class="subpage"> <?php $index_query = new WP_Query( array( 'post_type' => 'faq', 'orderby' => 'modified', 'posts_pe... | Here's a rewritten version of your code <code> <ul id="questions" class="subpage"> <?php $current_id = get_the_ID(); $index_query = new WP_Query( array( 'post_type' => 'faq', 'orderby' => 'modified', 'posts_per_page' => '-1', 'order' => 'DESC' ) ); while ( $index_query->have_posts() ) : $index_q... | single.php - how to mark current page in the loop | wordpress |
I've actually been searching on this site for the answer to this question for quite some time. Looking for a way to 'echo/print' multiple og:images for facebook. What I have here used only 'the_post_thumbnail' <code> function fb_image() { if (is_single()) { global $post; $feature_image = get_the_post_thumbnail($post-&g... | Figured it out with <code> function postimage($size = 'thumbnail', $qty = -1) { if (is_single() && !is_home() && !wp_attachment_is_image()) { global $post;$images = get_children(array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'posts_per_page' => $qty, 'post_mime_type' => '... | Multiple og:image for Facebook | wordpress |
I've got a WordPress site with a few plugins installed, and it takes a long time to load. I'm concerned about this; I don't want visitors just giving up and leaving, also Google takes page speed into account in its Page Rank. Is there a way I can speed up my site without removing any of my plugins? | Try using a caching plugin. There's plenty available, the two most popular being WP Super Cache and W3 Total Cache . If you're just starting out with caching, I'd recommend W3 Total Cache, as it is rather easy to set up and includes a lot of options. It's even used by some of the bigger sites such as iPhoneClub.nl, The... | How to speed up my site | wordpress |
I am using theme my login plugin and want to replace message when people registered and it's redirect back to login page with displaying message at the top of the form. Message: <code> Your registration was successful but you must now confirm your email address before you can log in. Please check your email and click o... | The below should work as is (with your strings for the new message and the theme's text domain), when inserted in your theme's functions.php : <code> function wpse71032_change_tml_registration_message( $translated_text, $text, $domain ) { if( $domain === 'theme-my-login' && $text === 'Your registration was succ... | Change success message in plugin Theme my login | wordpress |
I have created a custom post type and disabled it from appearing in search results. However when I add a link from a normal post, I still get these entries from my custom post type available to link to in the internal linking box (at the bottom when of the popup when you click the link button in the editor). How can I ... | I suggest making it private ( <code> 'public' => false </code> when registering the post type). You could club it with <code> 'show_ui' => true </code> to still display the admin interface. See the codex for <code> register_post_type </code> for full reference http://codex.wordpress.org/Function_Reference/registe... | Removing custom post type from link search results | wordpress |
Why <code> wp_commentmeta </code> table does not have a composite index <code> (comment_id, meta_key) </code> by default? I believe it's the only useful index for that table, am I wrong? Instead, it has a strange set of indexes: <code> mysql> show create table wp3_commentmeta; ... PRIMARY KEY (`meta_id`), KEY `comme... | A standard WordPress schema "sync" via <code> dbDelta() </code> will only add indexes, not drop them. Same goes for fields. We never touch the storage schema either, so it'd be the default for MySQL (which in latest versions is now InnoDB). On the face, a <code> comment_id_meta_key </code> index makes perfect sense. Bu... | Lack of composite indexes for meta tables | wordpress |
I need to print a specific term with its id. I get that for categories with this code: <code> <a href="<?php echo get_category_link(1); ?>" title="<?php echo get_cat_name(1);?>"><?php echo get_cat_name(1);?></a> </code> … where 1 is the id I have to print. Is there something like the follo... | Use <code> get_term() </code> to get the name, slug, or description: <code> $term = get_term( 1, 'taxonomy_slug' ); // Name echo $term->name; // Link echo get_term_link(1, 'taxonomy_slug'); // OR echo get_term_link( $term ); </code> | get a specific taxonomy term name | wordpress |
I'm taking two templates and molding them into one that suits my needs. I'm getting this weird issue where things are repeating themselves just before the footer. Here's the code: <code> <?php get_header(); ?> <?php if ( get_option('mycuisine_blog_style') == 'false' ) { ?> <?php if ( get_option('mycuisin... | The loop in your code: <code> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> </code> is saying "if I have posts, display them all - by the declared # per page" So you need to modify the loop to only display the content you need. Can you provide some information on where the content such as ad... | doubled content | wordpress |
I want to list 10 last posts of author in author.php template. I used this code: <code> <?php while (have_posts()) : the_post(); ?> <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li> <?php endwhile;?> </code> But I can see only the last post of current ... | The easiest way would be to simply add: <code> global $query_string; query_posts( $query_string . '&posts_per_page=-1' ); </code> just before your code so you get : <code> <?php global $query_string; query_posts( $query_string . '&posts_per_page=-1' ); while (have_posts()) : the_post(); ?> <li><a... | list author's posts in author.php | wordpress |
I am learning WP_query and recently ran into a problem. I need to do a query where i first filter trough one or more custom fields, which works great thanks to meta_query. However, i also need it to order by multiple custom fields. (Like in sql you can write "ORDER BY field ASC, field2 DESC") This is what i have so far... | I am sure there are more elegant solutions, but this is what i came up with and it works for now... global $wpdb; <code> $querystr = " SELECT wposts.* FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta, $wpdb->postmeta wpostmeta2, $wpdb->postmeta wpostmeta3 WHERE wposts.ID = wpostmeta.post_id AND wposts.ID... | Wp_query order by multiple custom fields? | wordpress |
Right now there is a link and I am using a plugin for a modal box and I would like to change the link in the code. Where is the html and php file with the code located? I have looked in my theme files, but comments.php do not contain the code I need to change. Can I hack it via functions.php hook? | the link is called from within <code> comment_form() </code> (/wp-includes/comment-template.php line 1539) : <code> 'must_log_in' => '<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $... | How can I change the link in comment form "Log in to post a comment"? | wordpress |
I have a blog on wordpress say example.com with a page name "mypage" in it. When a user clicks on mypage I want him to redirect to mypage.example.com (a subdomain that I have already created) inspite of opening example.com/mypage. I want my page to redirect to my subdomain. I am a user of wordpress and hence I dont kno... | Can you use a custom menu ( Appearance -> Menus ) ? If so, just create a custom link and insert it where desired. This has the added benefit of not cluttering your list of pages with a page that isn't real. | How to redirect a page to subdomain? | wordpress |
In the Media Library, when I go in to attach a media item to a post, I know I can use "Attach" to pull up the "Find Posts or Pages" pop up. This brings the following list of post title, date and status. I wonder if there is a way to have the results show the post ID as well? It might have something to do with the <code... | You cannot do that with pure PHP. The table is created in <code> wp-admin/includes/ajax-actions.php::wp_ajax_find_posts() </code> , and there is no filter. But look at the radio buttons: <code> name="found_post_id" value="' . esc_attr($post->ID) </code> You can print a script on the action <code> admin_footer-upload... | Show Post ID in "Find Posts or Pages" box in Media Library? | wordpress |
I have a custom interface that uses 30+ ajax files while running... some files are only used in category.php while othere's are only used in page.php... i include the ajax loader php files in my functions.php file example: <code> include TEMPLATEPATH . '/ajaxLoops/ajax-open_client_editform.php'; include TEMPLATEPATH . ... | When you call admin-ajax.php no query is being produced so <code> is_page() </code> or <code> is_category() </code> or any query based conditional tag will never return true. A better way would be to include your files inside the ajax callback, meaning something like this: <code> add_action('wp_ajax_PAGE_ONLY_ACTION','... | Conditional Ajax inclusion | wordpress |
We have a WordPress site where we have external authors for whom we have created usernames at the <code> Editor </code> level. We want these editors to be able to create new posts and modify their own posts, but occasionally we have posts in progress that we'd rather keep more private. It is a very small pool of users,... | If you look at Wordpress's explanation of Roles and Capabilities , you will see that the correct role you should have assigned them is Author. That being said, if you for some reason don't want to change them to Authors, you can alter the capabilities that a role has. See the full list of Editor capabilities here. <cod... | Apply permissions per post | wordpress |
I'm wondering how it's possible to add custom post type categories as an option to add as a navigation menu item. What I have: <code> $portfolio_args = array( 'labels' => array( 'name' => 'Portfolio Items', 'singular_name' => 'Portfolio Item'), 'description' => 'Allows you to build custom portfolio items an... | If you don't see your taxonomy, check under the <code> Screen Options </code> tab in the upper-right corner of the admin window and make sure the <code> Show on screen </code> check box is ticked for that taxonomy. | Get custom post type categories to show up in menus | wordpress |
Here is what I'm basically trying to accomplish: I have a custom post type called 'quotes' I have a number of wordpress pages What I am trying to do is this: each time when I create a new "QUOTES" post, I want to be able to choose on which page this quotes post is supposed to go. I've decided to do this by creating a n... | You are using <code> checkfield_<?php echo $page->ID; ?> </code> as name for your input fields, then trying to save <code> $_POST['checkfield'] </code> which is not set. You can do the same <code> $pages </code> loop on the <code> myplugin_meta_save() </code> function and then save the data for each page as se... | Listing Pages With Checkboxes In a Metabox (and saving them) | wordpress |
On the Google developer API page, it talks briefly on retrieving a dynamic list of fonts using JSON/JavaScript. I was wondering how would I be able to pull the web fonts API into my Wordpress theme so that I'm not creating my own list or have to constantly release an update of fonts. Thank you. | Here is some quick first draft code for populating a dropdown from the Google Font API, I do not know about the options framework so this will not deal with that. 1. Get an API Access Key from Google Your request will need a valid key, you can follow the instruction here on how to get one: https://developers.google.com... | API JSON Data in WordPress | wordpress |
I am about to create a new plugin that fetches remote content and stores it locally for use on the WP website. I have a free plugin that does this with twitter and tweets, and I store a JSON file in the plugin directory. Some users complain that the plugin cannot write files to the folder due to permissions. For this r... | Look at the table schema in <code> wp-admin/includes/schema.php </code> : <code> // regular blog tables CREATE TABLE $wpdb->options ( option_id bigint(20) unsigned NOT NULL auto_increment, option_name varchar(64) NOT NULL default '', option_value longtext NOT NULL, autoload varchar(20) NOT NULL default 'yes', PRIMAR... | How much string content can I store in an option? | wordpress |
I recently installed the bonpress theme and am having trouble with the captions showing correctly. The more I try to understand how captions are supposed to work in Wordpress, the more I suspect something is not happening right with my installation. When creating a post and inserting an image with a caption, Wordpress ... | Find the line <code> /* Remove [caption] in-line styling </code> in <code> function.php </code> . Comment out: <code> /* add_shortcode('wp_caption', 'fixed_img_caption_shortcode'); add_shortcode('caption', 'fixed_img_caption_shortcode'); function fixed_img_caption_shortcode($attr, $content = null) { // Allow plugins/th... | Caption shortcodes not including caption as attribute | wordpress |
I use this plugin to echo the URL of a post's featured image in the header: <code> <?php /** Plugin Name: Post Thumbnail FB header */ function fb_header() { // Not on a single page or post? Stop here. if ( ! is_singular() ) return; $post_ID = get_queried_object_id(); // We got no thumbnail? Stop here. if ( ! has_pos... | Use the second parameter of <code> wp_get_attachment_image_src() </code> : <code> $size </code> . <code> $att = wp_get_attachment_image_src( $att_ID, 'large-thumb' ); </code> or <code> $att = wp_get_attachment_image_src( $att_ID, array ( 900, 300 ) ); </code> The size is passed to <code> image_downsize() </code> and th... | Echo URL of large version of Featured Image | wordpress |
I'm not very clear how to restrict admin area post types access to specific user roles. In my case, I have some post type such as "suppliers" which I do not want to show to "authors". By default WP allows authors to browse, add or edit their own content. But I don't want my authors to add a "supplier" or browse entries... | For the solution to your question, In the <code> register_post_type </code> arguments, use the <code> capability_type </code> parameter & then grant the specific capabilities to the users. For instance, if you set <code> 'capability_type' => 'supplier' </code> , grant the <code> edit_supplier </code> capability ... | How to restrict specific post types from being read or added by specific user roles (eg. author)? | wordpress |
I have a pretty good question here. I would like to create a hidden page on my wordpress blog for each user as they are registered. I already have most of the code of what needs to be put on the page with a simple shortcode. All I need is something to actually make the page. Here is some of my code. <code> <?php fun... | Create a stackexchange-url ("custom post type") named <code> userinfo </code> . On <code> 'user_register' </code> call <code> wp_insert_post() </code> in your filter, and create a new post for the user. Add the user ID as post meta field. When the new page is called on the front-end, display the user data. | Create pages for authors | wordpress |
I am doing a survey using the plugin "Contact Form 7". I want to insert an acceptance box. ONLY if people check this box and click "submit", they should be redirected to another page, where I am going to ask for their e-Mail-addresses. If they don't check "acceptance" there should be no redirecting. How can I do this? ... | I found an answer myself: Redirecting without a condition When you use the Wordpress plugin “Contact Form 7” you can redirect the user to another page after submitting the answers by the follwing code: <code> on_sent_ok: "location.replace('http://www.redirectedpage.com');" </code> The line of code you have to copy into... | Contact Form 7: Redirecting on a condition? | wordpress |
I use the Breadcrumb NavXT plugin for a WP Multisite. I activated the plugin for all sites so I can use it throughout my network. My problem is that every time I add a new site I have to change the default settings of the plugin, but I’d like WP to use the settings I already customized for the main site because on all ... | Nice Question! But I'll leave for the asker and for the reader the task of finding the plugin options name . This can be used for any plugin/theme that relies in a single/serialized value in the <code> wp_options </code> table. If it's not a single value, it's another task... In this example, I'm using WP-Pagenavi <cod... | Inherit plugin settings to new site in Multisite | wordpress |
I have an if statement already in my loop to display content based on post type. I was wondering if there was a way that I could say to ignore that section if it is the front page/homepage. Here's a sample of my code: <code> <?php if( get_post_type() == 'reviews' ) { ?> <div class="post-review"> <div cla... | Check for <code> is_front_page() </code> and if you want to catch the first page only inspect <code> get_query_var( 'paged' ) </code> too: <code> if ( is_front_page() and 2 > get_query_var( 'paged' ) ) { // we are on the first page of the front page } </code> | Adding if statement to content for homepage | wordpress |
I am using woocommerce for a "multi-seller" system. Meaning one site (no multi-site), but many sellers with different products. To let each owner only manage it's own orders, it would like to filter all orders before they are shown in the admin area . The criteria for filtering could be a tag or the creator of the prod... | WooCommerce does not support this specific scenario. The primary issue in this case being that WooCommerce processes orders at the order level NOT the line item level. So if a customer were to order items from multiple sellers you create a situation that will cause serious problems and headaches. When the first seller ... | Filter WooCommerce Orders | wordpress |
I have a situation where I need to provide a dropdown of pages in a widget, based on whether they are using a specific template. In other words, for all pages using template 'Foo', get the post ID. I have coded the rest of the widget, but I'm using an input field for entering a page ID (which can get messy with non-tec... | WP_Query goes only through posts by default. Try adding <code> page </code> as your post type: <code> $the_query = new WP_Query(array( 'post_type' => 'page', /* overrides default 'post' */ 'meta_key' => '_wp_page_template', 'meta_value' => 'templates/_partner.php' )); </code> See: WP_Query - Type Parameters | Get page IDs based on which template they are using? | wordpress |
I have constructed this query to sort posts on the home page by a set position number in a custom field. However, I need to be able to exclude posts with the position set to '0'. Below is the code working to sort the items, but I cannot get anything to work with excluding the posts. <code> <?php query_posts('meta_ke... | <code> $args = array( 'meta_key' => 'home_post_id', 'orderby' => 'meta_value_num', 'order' => 'DESC', 'meta_query' => array( array( 'key' => 'home_post_id', 'value' => 0, 'compare' => '>', 'type' => 'numeric', ) ) ); query_posts($args); </code> Something like this should work but I haven't te... | Exclude posts by post meta value | wordpress |
As of now my uploaded files are organized by year and month. But I would like to organize them by year, month and day. I mean like this <code> 2012/10/30/image goes here </code> PS: There is a plugin available to do this. But I don't want to use a plugin for this simple task. Thanks | Code based in other stackexchange-url ("Answer of mine") and this stackexchange-url ("SO Answer"). It uses the post/page/cpt publish date to build the paths. Note that <code> $the_post->post_date_gmt </code> is also available. <code> add_filter('wp_handle_upload_prefilter', 'wpse_70946_handle_upload_prefilter'); add... | Organize uploads by year, month and day | wordpress |
I want to prevent site to be accessible by ip. It could be accessible by only domain name, so I tried with htaccess trick. <code> RewriteCond %{HTTP_HOST} !^mydomain\.com [NC] RewriteRule .? http://mydomain.com%{REQUEST_URI} [R=301,L] </code> It did the trick now my siteurl is changed to mydomain.com instead of my ip. ... | WordPress does not create a complete new .htaccess. It just rebuilds the part between the WordPress markers: <code> # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L] RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} ... | Redirect from ip to domain | wordpress |
In my plugin's options page, I'd like to have custom GET parameters. WordPress already has a "?page=" GET parameter, so simply linking to something like "?myparameter=value" won't work. I though of reading the "page" parameter, and then linking to something like: "?page=&myparameter=value". This seems workable, but... | I'd recommend using <code> add_query_arg() </code> : <code> $url = add_query_arg(array( 'foo'=>'bar', 'custom'=>'var', 'page'=>'myadminpage' ), admin_url('admin.php')); </code> The second argument, <code> admin_url('admin.php') </code> , is optional - and if omitted it uses the url of the current page you are ... | Custom GET Parameters In Plugin's Admin Page | wordpress |
I use my custom Pagination function on my web site; <code> #Pagination function pagination($prev = '«', $next = '»') { global $wp_query, $wp_rewrite; $wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1; $pagination = array( 'base' => @add_query_arg('paged','%#%'), '... | I think your problem with pagination. Use this code and css. <code> <?php function pagination($pages = '', $range = 4) { $showitems = ($range * 2)+1; global $paged; if(empty($paged)) $paged = 1; if($pages == '') { global $wp_query; $pages = $wp_query->max_num_pages; if(!$pages) { $pages = 1; } } if(1 != $pages) {... | pagination hook doesn't work with search results | wordpress |
I seem to have a problem customizing the Twenty Eleven theme. I would like that the top header above the header image to have a background color that goes from side to side in the window. Found out that the problem may come from max-width set to 1000px, but could not find where to put it so it doesn't mess up the theme... | In your Twenty Eleven child theme (don’t edit the main theme!) create a new <code> header.php </code> file, copy the content from the parent theme, and replace this part: <code> <body <?php body_class(); ?>> <div id="page" class="hfeed"> </code> … with something like this: <code> <body <?php bod... | Twenty Eleven header resize | wordpress |
I have a question after reading this post (stackexchange-url I like this function(Search Term Without Plugin) very much but the character length is too long. What php code should i add to make the excerpt shorter? Would appreciate if someone can suggest it. Thank you! | add these lines in function.php file <code> function custom_excerpt_length( $length ) { return 20; } add_filter( 'excerpt_length', 'custom_excerpt_length', 999 ); </code> | How can i limit the character length in excerpt? | wordpress |
I'd really like to take all of my old posts, and automatically use the meta descriptions we have written – currently done for each post using All In One SEO Pack – and copy them to also be our post excerpts. The custom field used by AIO SEO description is <code> _aioseop_description </code> . Would anyone have any idea... | Please , backup your database before running this . The code is pretty straight forward and tested in a local WordPress. The advice is just for precaution sake, as I suppose you're dealing with a live site. Copy the code into a PHP file, upload it to the plugins folder and activate. On activation, it will iterate throu... | Copy SEO Meta Desc "Custom Field" to Excerpt field? | wordpress |
I'm doing some url and meta cleanup and have found a strange problem(?) where, when adding a number to a url, the url still works. For example: The following uris both work and retrieve the same information: <code> /2012/06/21/graduation </code> <code> /2012/06/21/graduation/29/ </code> This numeral addition works with... | That’s an old problem, and I have never looked deep enough explain it. But I have a plugin for that, written a long time ago . It still works, but keep the age of the code in mind when reading it. :) I didn’t change much for this repost. <code> <?php /* Plugin Name: T5 Canonical Permalink Plugin URI: http://toscho.d... | Appending numbers to url do not break the link | wordpress |
I'm following this turial on how to add a custom button to TinyMCE editor in WordPress. Trying to edit author's JS to include my functionality, yet it seems to have gotten cached. Article author has a hack for it (code snippet below), and it did work for the first time (the button is in the toolbar now), although it do... | Turns out the 'no plugins activated' was not enough. Once I did a completely fresh install ( without W3 Total Cache plugin), the issue disappeared. | prevent caching during tinymce custom button development | wordpress |
I'm looking for an solution how I can count and display all queries in a WordPress site. Does anybody know, if there is an good plugin? Otherwise it would be an solution to check the queries on the console, because I'm working a lot with the console. | You can paste this block of code in your currently active WordPress theme <code> functions.php </code> file: <code> function wpse_footer_db_queries(){ echo '<!-- '.get_num_queries().' queries in '.timer_stop(0).' seconds. -->'.PHP_EOL; } add_action('wp_footer', 'wpse_footer_db_queries'); </code> The above block o... | Count & Display Database Queries | wordpress |
I'm trying to add a feature to my loop.php to use with a custom post type. However, I don't want it displayed on all posts, just the ones that are the custom post type (let's say its called "review"). Is there a way to say if post type = review then show this new section, otherwise hide? I tried using <code> <?php i... | Try the following: <code> if ( have_posts() ) { while( have_posts() ) { the_post(); if ( 'reviews' === get_post_type( get_the_ID() ) { echo 'I am a post of the post type &rdquo;reviews&ldquo;'; // We're done here, continue to next post continue; } // Do other stuff } } </code> EDIT In case you're not sure if yo... | Added if statement to loop | wordpress |
I am wondering if there is a way to manually change the author of images. I am using Gravity Forms which sets the post author to the current user but does not set them as the author of the images they upload. I figure there might be a way to add a function which finds the current user and then sets the author of the im... | <code> add_action("gform_user_registered", "image_author", 10, 4); function image_author($user_id, $config, $entry, $user_pass) { $post_id = $entry["post_id"]; $args = array( 'post_parent' => $post_id, 'post_type' => 'attachment', 'post_mime_type' => 'image' ); $attachments = get_posts($args); if($attachments)... | How to change image's author via a function when using GravityForms uploader? | wordpress |
Is there any way to restrict certain category’s posts or certain posts from being displayed into site default feed after published? I’m asking this because I don’t want few specific categorie’s posts to be sent to my feedburner subscribers. I think preventing them from displaying into site feed will also prevent them t... | Simple answer is yes you can. :) First check out Wordpress's codex here on their RSS feeds. http://codex.wordpress.org/WordPress_Feeds Then what you can do is change the default head rss links that let browsers know that there is an RSS feed. In your theme find: <code> <link rel="alternate" type="application/rss+xml... | Restrict certain posts from being sent to the feed subscribers | wordpress |
So I have custom taxonomy called "shape" and another one called "color". If I want to get the list terms under shape that contain posts that are also present in terms under color , how do I do that? Example, I have a post under custom post type toy called Ball which is present in both shape Circle and color Red. I want... | This should get you the names of all such terms in an array <code> $wpdb->get_col("SELECT DISTINCT {$wpdb->terms}.name FROM {$wpdb->terms} INNER JOIN {$wpdb->term_taxonomy} ON {$wpdb->term_taxonomy}.term_id = {$wpdb->terms}.term_id INNER JOIN {$wpdb->term_relationships} ON {$wpdb->term_taxonomy}... | Get terms that contain posts that in turn belong to other terms? | wordpress |
I noticed that there are bunch of operator can be use for compare in meta_query. However, I am not quite sure what operator I should use, it is somehow confusing like <code> = </code> and <code> LIKE </code> operator. I would like to know what exactly each operator mean, and in what condition I should use them. <code> ... | The first several work about like you would expect: <code> = equals != does not equal > greater than >= greater than or equal to < less than <= less than or equal to </code> <code> LIKE </code> and <code> NOT LIKE </code> are SQL operators that let you add in wild-card symbols, so you could have a meta quer... | Meta_query compare operator explanation | wordpress |
Is there an action or filter that gets called after an instance of WP_Query performs a query? | Yes there is, <code> the_posts </code> gets called just after the posts have been selected from the database and it passes an array of <code> $posts </code> as a first parameter and the <code> $wp_query </code> object as second parameter to your hooked function. | Which filter/action hook gets triggered after a query has been performed? | wordpress |
Does anyone here know weather or not a free theme on Wordpress can be used for commercial purposes? I am using the Pinboard theme. Would I need to get some sort of licence to operate the website as a business? | The Pinboard theme is in the WordPress theme repository and released under the GPL license, this means that you are free to use and redistribute the theme code. The GPL license gives you.... the freedom to use the software for any purpose, the freedom to change the software to suit your needs, the freedom to share the ... | Free themes for commercial use | wordpress |
Recently I've been developing sites for WordPress that are both increasingly complex but also have much higher rates of traffic. I remember when I was learning the ropes from another about PHP, that in cases of optimisation, "cases" are a better option than "IFs", as they put less load on the server. I've successfully ... | If you're using it on single templates, the easiest & most efficient way would be to switch based on the value of <code> get_post_type() </code> . <code> switch(get_post_type()) { case 'news' : // some statement for news type break; case 'sports' : // some statement for sports type break; default: // something to d... | How to use "Cases" instead of "IFs" for conditional logic | wordpress |
I've installed Responsive theme on my new blog . I want the home page to show my recent posts, so I configured <code> Settings->Reading </code> to show my 10 recent posts, instead of a static page. Alas, the static home page (with the "Call to Action button") remained. Any idea how to change it? | Yes and you can find out more on our support forum as well. Thanks for using Responsive, Emil | Show latest posts on responsive theme | wordpress |
Should be simple - I'd like WP to tweet the content of a post once (when it's published the first time) if the post format is 'status'. The code below isn't returning an error on publish, nor is it tweeting OR updating the post metadata, which leads me to believe I'm either using the hook incorrectly or there's somethi... | <code> $post </code> isn't available during <code> {$new_status}_{$post->post_type} </code> , but <code> $post_ID </code> is. We pass that to the function and then call in <code> $post </code> globally. I should have also been testing using <code> get_post_format() </code> , not for a type. After those corrections, ... | Auto-Tweet if Type is 'Status' using OAuth | wordpress |
I'm looking to pass custom nav_menus through an RSS feed so I can grab them on other sites to create the same custom menu on multiple sites. What I can't figure out by looking through the database is how WP is storing the data it needs to know which items are parent> child related for hierarchy. How does it know to out... | Each nav menu item is stored a post type named <code> nav_menu_item </code> . The horizontal position is stored in the column <code> menu_order </code> The vertical position (hierarchy) is stored as post meta field named <code> _menu_item_menu_item_parent </code> holding the parent <code> nav_menu_item </code> ID. To c... | How is custom menu hierarchy output handled? | wordpress |
I'm in a complicated situation. I'll try to explain it as easy as possible. Imagine the following pages: Page 1 Page 2 Subpage 1 Subpage 2 Subpage 3 Each subpage of page 2 lists posts from a custom post type with a specific taxonomy. Let's call the post type Objects, and the taxonomy just Categories, to keep it simple.... | The page template's filename is stored as a post meta with key '_wp_page_template', so basically you can use <code> get_post_meta($post_id, '_wp_page_template', true); </code> to get the template filename for the page with ID <code> $post_id </code> . You can also do the reverse (i.e. getting id from page template file... | Get page by template? | wordpress |
I have a custom made Twitter stream on my site. I want to have a permalink for each tweet which would go to a page which would display only the tweet - no other content - surrounded by my custom theme. Ideally I would get Wordpress to display a Page Template on a certain url (something like /tweet/<tweet_id>), bu... | I decided to use a Page and looked at how Exclude Pages hides them. This is what I came up with (in <code> functions.php </code> ): <code> add_filter('get_pages','mytheme_exclude_pages'); function mytheme_exclude_pages ($pages) { $showPages = array(); foreach ($pages as $page) { if (!in_array($page->post_name, array... | How to display non-page / post content | wordpress |
I want to be able to set the default time in the options for a Scheduled Post to be a specific time of the day, as opposed to it defaulting to the current time. Is there a plugin or some code I can add/tweak to accomplish this? I was unable to find anything here or on Google to do this. | The plugin Automatic Post Date Filler suggested in the comments is a perfect solution. Even better than imagined with all the various preferences to how it dynamically sets up the defaults when you edit the scheduled time. | Scheduled posts: set default time? | wordpress |
I would like to limit the number of posts which can belong to a given category, for example: The "News" category should have no more than ten posts. When the eleventh post is created the oldest post should be dropped from the category without the need to edit the post manually to remove it from the given category. Does... | Hook into <code> publish_post </code> . Check if the post is in the category <code> news </code> . Get all posts with that category: <code> $query = new WP_Query( array( 'category_name' => 'news', 'posts_per_page' => -1 ) ); </code> Update the category of the oldest post if necessary: <code> wp_set_post_terms() <... | Limit the number of posts a category can have - newest post goes in, oldest one drops out, possible? plugin? | wordpress |
For Wordpress, I want to auto generate thumb of the video embedded on a page using oembed? And then save it as a featured image of the post. Any idea how to do this? | I needed just this for a recent project, so here's my plugin! The code should be self-explanatory, but if there are any questions ask away. <code> <?php /** * Plugin Name: oEmbed Featured Image * Plugin URI: stackexchange-url * Description: Automatically set the featured image if an oEmbed-compatible embed is found ... | Featured Image of Video from oembed | wordpress |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.