Tag Info

Hot answers tagged

7

The post format taxonomy: The post format is a default taxonomy, registered with: register_taxonomy( 'post_format', 'post', array( 'public' => true, 'hierarchical' => false, 'labels' => array( 'name' => _x( 'Format', 'post format' ), 'singular_name' => _x( 'Format', ...


6

Use get_edit_post_link filter. add_filter('get_edit_post_link', 'get_edit_post_link_178416', 99, 3); function get_edit_post_link_178416($link, $post_id, $context) { $scr = get_current_screen(); if ($scr->id == 'edit-post' && $context == 'display') { return 'http://google.com'; } else { return $link; } } You can ...


2

I depends on your theme - they can be used for many things, but generally they are displaying in the list of the post, in the post itself (usually on the top of it). As well they are usually visible when sharing the link (for example in FB). But however, this is really pretty general question, you would have better to use google first (and maybe looking to ...


2

You need to use the get_page_by_title function : $post = get_page_by_title( 'Post Title', OBJECT, 'player' );


2

To save: // Update and save the field so it can be used in our template if ( isset( $_POST['input_name'] ) ) { $data = sanitize_text_field( $_POST['input_name'] ); update_post_meta( $post_id, 'field_name', $data ); } To read: $data = get_post_meta( $post_id, 'field_name', true ); // With post object, a leaner, cleaner method: $data = ...


2

Pro tip - don't custom query unless you need to (you don't). And never use the guid field. if ( is_singular() && $cats = get_the_category() ) $cat_id = $cats[0]->term_id; // Category ID for current post elseif ( is_category() ) $cat_id = get_queried_object_id(); // Category ID for current archive else $cat_id = 0; // No cats $posts = ...


2

By default add_action() only passes one parameter, not all three. Change your function to: add_action( 'transition_post_status', function ( $new_status, $old_status, $post ) { if( 'publish' == $new_status && 'publish' != $old_status ) { wp_die('STOP'); } }, 10, 3 ); Edited to add: The transition_post_status hook fires ...


2

Out of curiosity, I played around with static SQL queries and this one seemed to work: SELECT r.post_author, r.ID, r.post_title FROM ( SELECT p.post_author, p.ID, p.post_title FROM wp_posts p INNER JOIN wp_term_relationships tr ON ( p.ID = tr.object_id ) WHERE p.post_date < '2015-02-05 00:00:00' AND p.ID NOT IN (10,20) ...


1

Edited answer Thank you for you clarification above, and please give this a try - Note - This code assumes that you are using page.php, a variation of the page templage or some other custom template - it will not work on your index page (index.php). <div id="page-<?php the_ID(); ?>"> <?php if (have_posts()) : while (have_posts()) : ...


1

With what you are asking, it is really difficult to come up with some performant easy way that is also reliable. As @birgire already stated, his solution is not reliable, but from tests, it seem to be the fastest clocking in at 2 db queries in about 0.015s average. From a quick discussion between @birgire and me in comments to his answer, I've decided to ...


1

EDIT From comments, it seems I've missed the actual purpose here Here is an update: There is no way to tell that or to know that. Every theme is unique and how a specific user uses a post format is also unique. If you read my answer, status is used to display statusses like twitter. So in content-status.php you would have just maybe the_excerpt(). ...


1

You have to change: 'post_type' => 'post', To: 'post_type' => 'your_custom_post_type_name', And a all the reference to standard post. Also, you should add the filters only for main query or you can end up with issues in secondary queries. Bellow an example code for gallery custom post type. I was trying to debug the code you posted (taken ...


1

Unless I am completely misunderstanding what you are trying to do, there is no need to move your site into a sub-folder. The easiest way to do what you want is to simply create your static page in normal html just as you want it to appear. Then add the following code to the very top of your page... <?php /* Template Name: Front Page */ ?> Then ...


1

You can make use of properties on elements. Have a look at the following concept and see if you can use it. You basically hide all "featured" images. Add a general class to the post titles which you want to use to show/hide images. Add a property to the post title element which holds the id of the image you want to show. Generated MarkUp: <img ...


1

As stated in comments Most probably your posts per page setting for your site is less than 10 One have to remember, get_posts uses WP_Query. Any new instance of WP_Query and the main query (which also uses WP_Query) uses the value set for Blog pages show at most as default for the posts_per_page parameter when this parameter is not explicitly set by ...


1

I am developing front-end content management screen and want to point all edit links to point to the front of the website. If you want to point all edit links to the FE, you should go for the get_edit_post_link filter solution (see Marko's answer). That will cover all cases where either the core or a plugin calls get_edit_post_link(). But if you want ...


1

Since you've designated a specific page to be your Post Archive ( blog ) it no longer is a standard page; meaning is_page() will likely fail. Since your blog page is now more of an archive, it is automatically being returned because of your first conditional. is_singular() - Returns true when viewing a single page, post, or post type. So what you're ...


1

As your question does not state, I'm assuming that this is not your main query, but rather a stand alone that tells the visitor the most viewed page of the day. Therefore I believe that an instance of the WP_Query class is what you need. /** Query the posts to find the one with the most views from today */ $today = getdate(); $args = array( 'meta_key' ...


1

To accomplish this, you will need to know which is the last post on the page. There are a couple ways to achieve this, but I think the easiest way is to use pure php, the function end(). You are going to use this to get the last post in the loop. Once you have the last post in the loop, you can simply just compare the last post's ID with the current post ...


1

You need to add 'post_type' => array('post', 'opinion') to your $normal_args array and maybe remove the meta_query?. Are you sure you have any opinions with a _custom_blog_enhome of 1? Start from $normal_args = array( 'post_type' => 'opinions', 'post_status' => 'publish' ); and add arguments one by one and watch the results.


1

The post_date and post_date_gmt serves as the date that the post was created. For scheduled posts this will be the date on which the post is scheduled to be published. There is no reliable native method to determine the date when a scheduled post was added. For scheduled posts, you can try the post_modified or post_modified_gmt dates as this will correspond ...



Only top voted, non community-wiki answers of a minimum length are eligible