Tag Info

New answers tagged

0

If you want something to behave like a "normal" wordpress author then the best thing to do is to create a "dummy" account for it, and if you really want disable the possibility to login to it. For any other solution that mimics the functionality in other ways you first need to fully understand the functionality you are trying to mimic, and by your own words ...


3

As said in a comment, you can do this in one query. The principle here is to only display the date heading if the post date's month of the previous post does not match that of the previous post FEW NOTES Before I start, a few notes: Never use query_posts, except if you really need to break everything on a page. It not just reruns the main query and also ...


2

Updated Answer After thinking about the comment from @PieterGoosen below I've added a method of achieving the you goal by using a single query. I benchmarked the methods and the single query is faster, with the multiple query method being about 15% slower. Not a hugh margin, but every little helps, and to be honest the method can probably be refined ...


0

You can make use of the the_content filters to apply markup to get_the_content() $content = get_the_content(); echo apply_filters( 'the_content', $content ); You'll need to do the same for get_the_title() where you would use the_title filters instead of the_content Just another note on your code, remember to reset each of your custom loops with ...


0

The following bypasses wordpress by not going through index.php: http://prompter.rareapps.org/prompter.php?p=2193 I'd recommend that instead of doing that, you place prompter.php in your theme directory and then hijack the page to display when someone clicks the link to view full screen using the template_redirect filter: function ...


0

You can instead use the standard WordPress function wp_parse_id_list like this: $purchaseprodid = isset( $_GET['ids'] ) ? wp_parse_id_list( $_GET['ids'] ) : array(); that checks that the input data is not already an array, clears duplicates and converts the type of each array element to integer. More info at: ...


0

All the rendered content of the page is available to the page. How would it be rendered otherwise? jQuery('#content-textarea-clone').html() gives you the current contents of the editor window, using jQuery. And jQuery('textarea#content').html() holds the initial content of the page (the saved one).


0

No, that is correct, news has nothing to do with your structure... it's just a word... But you can get a way around it... you could copy archive.php and name it something like template-news.php then edit the template-archive.php... put this at the top... just below ' <?php /* * Template Name: News */ Then add a new page in your dashboard... make ...


0

Do not use query_posts, and for that matter any custom query to replace the main query. It is always problematic and it creates more problems that solving it. Use the main query and make use of pre_get_posts to alter the main query as needed. To solve your issue, remove the query_posts line, this is how author.php should look. <?php ...


0

The best way to add extra fields to the wordpress user registration form that I know of is to use the related registration form filters: register_form - This is used to add your fields to the registration form registration_errors - This is used to validate your fields user_register - This is used to add your custom user_meta data to the system and maybe ...


0

Use like this: <?php while ( have_posts() ): the_post(); // Display post if ( have_posts() ): the_post_thumbnail(); //call image that you set in featured image in each post on right sidebar of admin panel. the_content(); //call content endif; endwhile; ?>


2

There is no blog creation date in Wordpress. The first blog post is usually regarded as the blog creation date when you create copyright footer notes for a blog. This is not very reliable though. There are a few thing that happens by default when Wordpress is first installed, the most important being a user is created with ID 1. This is the most accurate ...


-3

**The default syntax for showposts is-** <?php $query = new WP_Query (array( 'showposts' => 5, ) ); while ($query->have_posts()): $query->the_post(); ?> <li> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> ...


0

The easiest solution is to use jQuery. Add the below code to any JS file that you include in the admin area. As you haven't given very much information above I don't know a couple of things, so you'll need to amend this example slightly - Change your-post-type to the slug of the post type for which this metabox exists. If it's the default Post then it'll ...


0

i dont see the problam in using WP_Query... it has an author parameter. $cuser_id = get_current_user_id(); $args = array( 'post_type' => 'campaigns', 'posts_per_page' => 100, 'author' => $cuser_id, ); $the_query = new WP_Query($args); if ($the_query->have_posts()) { while ($the_query->have_posts()) ...


0

So awkwardly realised I'd been going about this whole thing in a stupid roundabout way and in fact Milo above in the comments is completely right, and proves that the codex still has secrets for everyone, or maybe just me. The eureka (or durr-eka) moment came after reading this post here about setting up and editing the content of the metaboxes. Instead of ...


0

In Admin Panel go to Settings -> Permalinks -> at the lower left click on save changes to refresh all permalinks including your custom post type.


0

By default, you can view posts by authors with a URL of the form {home_url}/author/{author-slug}/ If you'll be writing any PHP and need to output a link to an author's posts, see the function get_author_posts_url. Edit: If you'll be writing your own author post page template, the filename should be one of the following formats: author-{nicename}.php, ...


0

What you can do is the following: http://codex.wordpress.org/Function_Reference/get_posts_by_author_sql <?php $where = get_posts_by_author_sql( 'post', true, $user->ID); // get post query global $wpdb; $query = "SELECT ID FROM $wpdb->posts $where"; $post_ids = $wpdb->get_var( $wpdb->prepare( $query, 'Get all posts' ) ); ?> Did not try ...


0

You can add category item Current Tenders in your menu directly which shows all the post of your category Current Tenders.


0

This is just a general idea, I can't give you code at this stage as I'm not in the position to code right now. You can try something like this: You will need to create a section in the theme customizer where users can set and choose between the different layouts Create separate stylesheets for the different layouts Load the correct stylesheet according to ...


0

The simplest solution is to add a query parameter, e.g ?view_as_grid=1 and a conditional to detect the query parameter <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php if (isset($_REQUEST['view_as_grid'])): ?> <!-- display the post as grid --> <?php else: ?> <!-- display the post as ...


0

Firstly, remember that because you are basing this on category IDs, you will need to save the post under category '5' before the box will appear. When I tested your code the meta box did appear after I saved the post, but you had an error. add_meta_box('team_meta', 'My Custom Meta Box 1', 'team_meta', 'post', 'normal', 'high'); This line should actually ...


1

Try: <?php if ( $the_query->have_posts() ) :?> <?php echo '<h3>' . date('l, F jS') . '</h3>'; ?> <?php while ( $the_query->have_posts() ) : ?> // etc.


1

Yes. get_post_modified_time : Retrieves the time at which the post was last modified.


0

Make sure that the Custom Post Type is public. Then create a page with the same name (slug). That shall do. To customize them make sure the CPT has an archive, then create archive templates such as archive-press.php, archive-speaking.php.


-1

Why not just use categories? Everything posted under the category "Speaking" goes to domain.com/speaking if you set the permalinks right :)


0

I've got the filter just for you: nav_menu_css_class function wpse_175057_nav_menu_css_class( $classes, $item ) { if ( $item->type === 'post_type' && $class = get_post_meta( $item->object_id, '_icon', true ) ) $classes[] = $class; return $classes; } add_filter( 'nav_menu_css_class', 'wpse_175057_nav_menu_css_class', 10, 2 );


0

A partial solution, that addresses the second half of your request -- i.e. limiting the number of posts allowed, on a per-user basis -- would be to use the "Bainternet Posts Creation Limits" plugin.


1

The best way I know of would be to filter the data. For posts, you might do: function my_check_post_not_crazy( $data, $post_arr ) { $max_content_length = 2048; # max length in characters $max_num_posts = 200; # maximum number of posts if ( !current_user_can('activate_plugins') && empty( $post_arr['ID'] ) ) { $die_args ...


0

Yes it is possible but not exactly trivial or well documented. The easiest option is to have different comment types (ie, have new ones in addition to the traditional comment, pingback and tracback). The biggest problem with this approach is that most of wordpress API and admin is not built to be flexible enough to sopprt different comments types, for ...


0

Problem solved, I've used this: $d=new WP_Query( array( 'category__in' => array(4), 'post_type' => 'post', 'posts_per_page' => '-1', 'orderby' => 'meta_value', 'order' => 'ASC', 'meta_query' => array( 'relation' => 'AND', array( 'key' => ...


0

Your's css is messed up becouse you have invalid html code. I'v counted 9 opening <div> tags and only 8 ( 7 in seccond code block ) closing tags Fix the html and your css will work just fine. About the_content() in your example it should work just fine, check if you have content added to post. When you'r using the_excerpt() check if your excerpt ...


1

Your code is correct. I have tested it and it works. I think what you are missing, and what I have missed while testing (banged my head against the wall for this mistake) is the fact that these posts do not show up at the top of your post list. Remember, by default, that posts are sorted and ordered according to post date, the newest posts showing up ...


-3

If you renamed it and its coming again and again then you need to install cache plugin and clear your cache then check .


1

You are missing a link. The posts are not assigned to the menus directly. There is a post type nav_menu_item in nav_menu taxonomy which links posts (or other kinds of destinations) to their place in menu. This snippet should get you started on retrieval: $menu_items = get_posts( [ 'post_type' => 'nav_menu_item', 'meta_query' => [ [ ...


1

There is no build in template assigment for indivual standar posts from edit screen. But you can assign templates for individual posts. There are several options: Use WordPress template hierarchy system Under the root folder of your theme you can create this files: single.php for all single posts of any type. single-post.php, if this file exists, it will ...


1

Instead of checking for the post type, you can also use publish_{post_type }. In your case publish_news function run_on_publish_wpse_100421( $postid, $post ) { // your code } add_action('publish_news','run_on_publish_wpse_100421',1,2);


1

The Image added by Add Media is included in the Content.So I have splitted the image from the content.Below is the working code for my Question. <?php $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); ?> <div class ="single-post-flex-slider"> <ul class="slides"> <?php ...


1

Here's a hack for the main post query in wp-admin that should do the trick: /** * Modification of the wp-admin main (post) query: * If current user has the "client" role then * show client's posts OR posts where the "client" meta value is the client id. * * @see http://wordpress.stackexchange.com/a/173967/26350 */ function ...


0

Open WP-Admin Editing File: Open the file located at: /example.com/public_html/wp-admin/edit-form-advanced.php Edit: Edit these lines to look like the next, adding target=”_blank” to each link or pasting the whole list. $messages = array(); $messages['post'] = array( 0 => '', // Unused. Messages start at index 1. 1 => sprintf( __('Post updated. ...


-2

//Post, page or all register custom post types function im_duplicate_post_link($actions, $post) { // get all post type which is register $posttypes = get_post_types(array('public' => true), 'names', 'and'); foreach ($posttypes as $post_type) { $posttype[] = $post_type; } //check current post type is in "$posttype" array, ...


0

My best practice to run a production system and keep a development version with a simple and easy configuration. Notice: This works super awesome on small wordpress websites. Create production and development configuration files: wp-config-dev.php (contains local database configuration, site url and debugging) _wp-config-live.php (contains production ...


0

These links are generated by alx_social_links() function. So in your functions.php file, search for alx_social_links() function and this link specifically. echo '<li><a rel="nofollow" class="social-tooltip" '.$title.' '.$link.' '.$target.'><i '.$icon.' '.$color.'></i></a></li>'; and remove rel="nofollow" from it. So ...


1

I found the solution to my problem: wp_delete_post(url_to_postid("url"));


0

When you are using Google CDN hosted version of jQuery then you don't need to use jQuery wrapper. It's for jQuery packed with WordPress core because jQuery with WordPress runs in noConflict mode. So your jQuery code will be. <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script type="text/javascript"> ...



Top 50 recent answers are included