Tag Info

New answers tagged

1

Once a post is moved to the trash and deleted, it's gone from the database. The only way to recover it is from an earlier database backup. Do you have a backup? Does your webhost have a backup?


0

So digging around a little i couldn't find a solution where the WP_Query wasn't used, so i just stuck with the query method, Using WP_Query this snippet will display the latest post that is published by the user that is logged in. $user_id = get_current_user_id(); $args=array( 'post_type' => 'POSTTYPE', 'post_status' => 'published', ...


0

You can use get_terms. In your case, something like this ought to get you started: $term_list = get_terms( 'taxonomy_name', 'hide_empty=0&orderby=name' ); foreach( $term_list as $term ) { echo "<li>" . $term->name . $term->description . "</li>"; }


2

I don't think you need so many transients set, one for each category. You can only use one, that is enough. Transients are quite expensive to set as it requires additional db queries, so you would want to cut down on the use. As always, I like to keep my templates simple, short and sweet, so I tend to write custom functions to move the bulk of the code ...


1

Normally, posts are published by the wp_insert_post() function. Essentially, the post_status is changed from draft to publish. Nothing more to it than that, really. There is also the wp_publish_post() function, which is really only used for scheduled posts. It does the basic job of transitioning a post from "future" to "publish", and also calls the same ...


0

Your category is ID being changed at every loop iteration and you are setting a common transient, which gives the same result every time even if category ID has been changed. So you need to save transient for every category. set_transient( 'category_posts_' . $category->cat_ID, $category_posts_query, 36 * HOUR_IN_SECONDS ); Try this solution ...


0

I was able to solve this by using below code. Maybe for some one it is helpful. // Values to be updated $in_stock = '1,5'; $out_of_stock = '20,30'; $in_stock_s = '5'; $out_of_stock_s = '30'; //FOR VARIATIONS // Get variations $args = array( 'post_type' => 'product_variation', ...


0

I don't know of a plugin! Wordpress stores uploaded images in a media library which puts them in the posts table. As you have copied and pasted they are not in the media library, but just as img tags in the posts/pages themselves. Step 1 - copy the image files themselves, using an FTP to download them all then put them in ...


2

You want the first parameter ($post_type) of register_post_type() – by default this is used for the "slug", so in your case it's: content-block The name and singular-name labels you refer to are just for display purposes – see get_post_type_object() for an example. So this should work (note I've not tested the rest of your advert code): if (! is_single() ...


0

You have to test if its the specific page in your case it might be waystoexplore.com/10-westport link. The code will be like this: if(is_single()){ the_post_thumbnail(); } or directly edit you single.php (most of the cases) and add the line <?php the_post_thumbnail();?> where you desire your featured image to show. For further references please ...


1

you may use <?php the_post_thumbnail();?> to display the image where you wish. If you still have any problem then please share the code you are using


1

I think this is more a general question than a specific one and I'll be treating it as such. Taxonomies in general are used to group posts together that shares the same characteristic. The post_tag and category taxonomies are the most widely and commonly used of the four build in taxonomies to achieve this. Also very popular are custom taxonomies which ...


2

WordPres has a function that extract IPTC info from images, that function is wp_read_image_metadata. That function is only available on admin side and, according with the codex, it doesn't extract IPTC keywords. But you can use iptcparse from PHP at your own to extract IPTC keywords and set them as post tags. In your question, you said that you have already ...


-1

It depends. To extract the IPTC keywords you will have to find a library or a code sample that you can use as I don't remember anything in wordpress doing that. As for using the keywords as tags for posts, in theory it is possible. The main issue with it is that images are not attached to posts in a "hard" way. A post just includes a url of an image so ...


1

I have accepted the @websupporter answer according to my question. However I would like add few codes to specific question I have faced earlier. I need to remove Yoast SEO plugin extra columns from the non admin users. In that specific case Yoast SEO provide the hook to disable the columns. So I used that as below. /** Remove SEO columns when User is not ...


0

Your problem is $tax_country, more actually the value. get_the_term_list() does not return what you think Returns an HTML string of taxonomy terms associated with a post and given taxonomy. Terms are linked to their respective term listing pages. Even if you strip away the tags, you will just be left with a string of term names. WP_Query (which is used ...


1

get_post() returns a post object. So you can try the following $post = get_post( 1571 ); setup_postdata( $post ); the_title(); the_content(); wp_reset_postdata();


2

You can just grab the first post from the main query and see which post type it is: if ( have_posts() ) { $post_type = $wp_query->posts[0]->post_type; } If you run this code directly in a main template file you should be fine, but if it's in a function you will need to call global $wp_query; first.


2

I assume, you need something like editors can't see the category column or something like this. This snippet might help you: /** Remove "Options"-Panel, when User is not admin **/ add_filter( 'manage_posts_columns', 'change_columns_for_user', 10, 2 ); function change_columns_for_user( $columns, $post_type ){ if( 'post' != $post_type ) return ...


2

You can use the capabilities API to conditionally set screen options: if ( current_user_can( 'manage_options' ) ) { // Administrator, add some options } else { // Other roles, do something different }


0

I would agree to the comment by Howdy_McGee to use Custom Fields. A nice implementation would be possible with add_meta_box(). 1. Approach: The body_class Filter So for example, you could let him enter a custom field 'color-scheme'. In the next step, you could simply hook into the 'body_class'-filter and add another class to the <body>-tag ...


0

You don't specify the difference in details, but I would guess the two themes aren't any, or at least much, different outside of color scheme. My approach would be simply to implement one (or both) color schemes as secondary CSS stylesheets to enqueue conditionally and stick with same theme for both of them.


2

WordPress has built-in support for posting via email. Go to Settings > Writing in your admin and enter your credentials under "Post via e-mail". Note it won't handle Gmail labels (it only works via POP3).


1

I'm not quite sure what you want to do as frankly, your terminology is a bit scrambled, and you example shortcode is also quite a mess. Before I start, you should start of by checking the following very important links Shortcode API WP_Query You should first start of by defining your attributes (and their defaults) which you need to use and pass to the ...


0

Wp Hide Post plugin will help you - https://wordpress.org/plugins/wp-hide-post/ This plugin has ability to hide a specific post on "Home Page or Category Page or Archive Page" etc. In your case create a category Technical Notes, add this to you nav menu or wherever you want. After installing the plugin, you'll see a new options has added at the right side ...


1

If I enter this shortcode: [download url="http://example.com"]Download[/download] it works fine. But you have to enter the link text as content yourself. You might have missed that, the way I read your question. Your [demo]-Shortcode throughs an error. To see this, you need to have WP_DEBUG set to true: Notice: Undefined variable: func in ...


0

If you want to display post in three columns by category then you can choose my best answer this question, but it’s hard because I can’t give a “one solution fits all” answer. The code I provide here will have to be changed and adapted for your own theme. Everyone’s theme is slightly different, so all I can really do is give a generic response and hope that ...


0

Their archives will use archive-{post_type}.php 'has_archive' => true, has_archive (boolean or string) (optional) Enables post type archives. Will use $post_type as archive slug by default. Default: false


0

First you should make some improvements to your template file. Try this: <?php get_header(); ?> <?php global $woo_options; ?> <?php if ( $woo_options['woo_featured_disable'] <> "true" ) include( TEMPLATEPATH . '/includes/featured.php'); ?> <?php $args = array( 'post_type' => 'infobox', 'order' => 'DESC', // DESC for ...


0

Did you enable WP_Debug ? Go to File Manager. Locate the wp-config.php file for your WordPress website. Click Edit for the wp-config.php file. To enable WP_Debug, add the following code to the end of the file: /** * WordPress Debugging * * Set to "true" to enable wp_debug. Set to "false" to disable. * Do not include quotes when setting to "true" or ...


-2

the solution so far was: $page =get_page_by_path('my-slug', OBJECT, 'page'); if($page && 'trash'==$page->post_status) { wp_update_post(array('ID'=>$page->ID,'post_status'=>'publish')); }


3

There is not wp_undelete_post. You have to use any of these funcitons: wp_publish_post: if you want to move from trash to publish status. wp_update_post: to move from trash to any other status. For example, for a given post ID (of any post type, including pages): if( get_post_status( $post_ID ) == "trash" ) { wp_update_post( array( ...


0

This is can be because of following reasons. 1.Premalink problem. Go to settings -> permalinks and set to default. save and check if post is now showing. If its working fine then reset premalink structure to desired one (like postname), save and check. 2.rewrite problem in .htaccess file Check if url is re-written in htaccess file or if it is then it ...


0

Goto settings -> permalinks option and change the common settings. Check the post again. If this does not work then check the .htaccess file.


2

get_post_ancestors() returns all of the ancestors hierarchically. As you only want to display the 2nd level post title on 4th post page, you can do something like - global $post; $parents = get_post_ancestors( get_the_ID() ); if( count($parents) == 4 ){ // ancestor1 = 1st parent, ancestor2 = second. echo get_the_title($parents['1']); // index ...


0

Here you can read an article about how to deal with. You'll have some mandatory things to do such rewrite your taxonomy with the same name of the custom post type. http://someweblog.com/wordpress-custom-taxonomy-with-same-slug-as-custom-post-type/


0

The function you are looking for is get_post_ancestors() According to the documentation it returns an array of the ancestor page IDs


0

Use pre_get_posts to add a meta query to the main query: function wpd_date_meta_query( $query ) { if( $query->is_post_type_archive( 'your_post_type' ) && $query->is_main_query() ){ $meta_query = array( array( 'key' => 'Date', 'value' => date('Ymd'), 'compare' => ...


0

So I actually solved this myself. Its not the most elegant solution, but it works. I figured it would help somebody. I first created a new post status using register_post_status() in functions.php. I then used pre_get_posts() also in functions.php, in which I filtered the main query on my archive page to only display posts of the status 'publish'. ...


0

You can do it by using either of them get_comments() wp_list_comments()


0

Please User Role Permission Plugin For user wise Permission Link here


0

Found a solution here: function get_the_content_with_formatting ($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') { $content = get_the_content($more_link_text, $stripteaser, $more_file); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]&gt;', $content); return $content; }


1

get_the_content() returns unfiltered content, and using a shortcode you cannot use the_content() to return filtered content as you cannot echo inside a shortcode. Your best option here will be is to applying the_content filters to get_the_content(), something like: apply_filters( 'the_content', get_the_content() ); EDIT Exact usage, replace $output .= ...


3

Some of the code in OP is a bit old and depreciated, like caller_get_posts which was depreciated years ago. The correct parameter to use now is ignore_sticky_posts. Your query is also really inefficient and not good for performance. Here is how I would tackle this issue Use get_queried_object_id() to get the current post ID instead of the more unreliable ...


0

Please reset your permalink. Go to http://yourdomain.com/wp-admin/options-permalink.php and just click Save Changes button. Edited: Try these steps: Make sure the homepage exists. Go to Settings > Reading options, see which page is used for homepage and check this page's status. Update WordPress. Keep backup before you proceed. Check each of the ...


1

Which wp_get_recent_posts()do you retrieve the most recent posts. For meta data, like published date and modified date use additional functions. For the published date is the_date() helpful. For the modified date use the_modified_date(). The functions are a part of the Template Tags, useful for Theme and direct output. But she have also parameters to get ...


0

There are quite a number of ways to achieve this and to optimize this to make it efficient as well. Here is just a basic idea to achieve this by using the offset parameter in WP_Query and using the php function date() to get the current week number. First, you should get the current week number with date( 'W' ). You can decide to take this as your ...


0

It's easier to help when we can see your code. But here's something you can try: if ( is_singular( 'post' ) ) { // Your author bio code } Hope that helps!


0

The loop in a page loads only the content of the page. Thus you see only one post. You have to set up a "Page of Posts". You can find basic examples in the codex at Page Templates. But using it as static front page results in some problems. The links to follow pages will not work. You have to evaluate get_query_var('page') instead of ...


0

If you set the fields argument to ids in your query it will return only post IDs which you can then pass to other functions to fetch the data you need. Though that may save memory at the cost of increasing queries to the database.



Top 50 recent answers are included