New answers tagged

0

I think the problem might could be the logic with using checked... <input type="checkbox" name="aps_display_post_title" value="yes" <?php if ($aps_display_post_title != 'no') {echo 'checked';} ?> /> ...on the other hand then running sanitize_text_field on the checkbox value might also be causing the problem. Instead you might want to break ...


0

Your code will make the value yes only when the user fills the form. You could check if the meta is not there then make it checked, or try this: $aps_display_post_title = get_post_meta( $post->ID, 'aps_display_post_title', true ); $aps_display_post_title = ! ( 'off' == (string) $aps_display_post_title ); ?> <input type="checkbox" ...


-1

first of all you find directory of your partial-sidebar.php directory. when you find then Get_template_directory_uri(). then "../ " this means one folder back if your partial-sidebar.php is backed folder of plugin then use as "../Get_template_directory_uri()/wp-content/" as well as so on


2

If I understand you correctly you want to change the subject line of the email. The hook of your code only changes the content of the e-mail. There's a different hook for the subject: add_filter('comment_notification_subject', 'wpse_228315_comment_notification_subject'); function wpse_228315_comment_notification_subject($subject, $comment_id){ return ...


2

TL;DR: Use a child theme instead :) If we dig into the code for get_template_part(), there's an action there - get_template_part_{$slug} - which we could hook into. Digging a bit further, get_template_part() calls locate_template(), which calls load_template(). Unfortunately, there's nothing in either of these functions that seems to be pluggable, so we ...


2

I found that https://wordpress.org/plugins/pinterest-widgets actually has the needed functionality but doesn't mention it in the description. After installing and activating you can add a pinboard to a post by using the following shortcodes [pin_board url="http://www.pinterest.com/pinterest/pin-pets/"] [pin_board ...


0

Go to Pinterest site and open a pin which you want to embed on your post. Now you can find 3 dots near send button in the top of the pin. Click that dots and you can see "Embed" option. Now click that. Pinterest will give you 5 options to embed their content. Pin Profile Board Follow and Pin it button Based on your requirement, select the option and ...


0

The way I understand this, you're trying to filter wp_title to include your pagination data. You can change the format in the sprintf first parameter and other params as per your needs. Please use with caution. add_filter('wp_title', function( $title ) { global $paged // page number , $wp_query; // WordPress query data if( ! is_feed() ...


3

What I was looking for was transition_post_status. The documentation can be found here. What I did was to add one more filter add_filter('transition_post_status','myFunction');


1

If you are displaying the info in the front-end, hook into wp or init, otherwise init or admin_init will work on admin: add_action('wp', function() { if( current_user_can("manage_options") && ! is_feed() && isset( $_GET["my_plugin_show_phpinfo"] ) ) { ?> <!-- Output things --> <?php ...


0

You Need to hook into the template_include filter e.g. add_filter('template_include', 'my_function_name'); function my_function_name( $template ) { if ("example" == $name){ $template = dirname( __FILE__ ) . '/my-template.php'; } return $template; } I asked this on here a couple of years ago and have used it a few times since for projects :)


0

Accessing files within WP installation directly is a bad practice. While you can implement a custom core load routine, it is fragile and impossible to reliably ship in public plugins. There are different approaches to form submission in WP. On of the most appropriate ones (if slightly underknown) is sending form to wp-admin/admin-post.php and using hooks ...


0

the_content will return the whole content of the post and not particular part. If you want to access your particular part, then you can go for shortcode. For eg, if you have content like this in your post Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's [mycustomtextpart] standard dummy ...


1

Based on the source code of wp_publish_post(), you could update the post status without touching meta data and, at the same time, without losing post transition actions (you are missing them in your code) with something like this: global $wpdb; // Unkown $get_directories, you have not set it // in your sample code, I assume it is correct $directories = ...


0

Not sure about the problem with wp_update_post but it is a simple enough SQL query: global $wpdb; $query = "UPDATE ".$wpdb->prefix."posts SET post_status='draft' WHERE ID = '".$directory->ID."'"; $wpdb->query($query);


2

I don't think this should happen by default. From quick look through the code the only case in which update call should affect meta is if you provide meta_input in arguments to apply. As per comment the case might be that you are trying to interact with third party CPT and its code doesn't handle situation well. Note that "own file" doesn't matter much ...


2

After Milo's tutorship: I recommend first reading how to use AJAX in Plugins properly. – Milo yesterday and reading another questions on wp.stack, my problem was solved) Here is an examples of code from my rewritten files 1)get_state.php: ad add_action( 'wp_ajax_ajax_object', 'ajax_handler' ); add_action( 'wp_ajax_nopriv_ajax_object', ...


0

NOTE the difference between add_meta_boxes and register_meta_box_cb. When you register the meta boxes using add_meta_boxes, here is how WordPress calls do_action() /** * Fires after all built-in meta boxes have been added. * * @since 3.0.0 * * @param string $post_type Post type. * @param WP_Post $post Post object. */ do_action( ...


2

Post type names cannot contain capital letters. So behind the scenes, your CPT is probably called projectscpt rather than ProjectsCPT - hence it not matching the value in your array.


0

An update as I figured out somethings for myself: dialog.js is not part of the core jQuery UI and thus isn't available via the standard jQuery handle. I have found queuing it difficult and to differ in success over theme's I tried. If it works it looks, to put it nicely, a bit crappy so that requires more work. I settled with jquery and used a regular form ...


0

as per the answer given by Tim Malone, I have this working code: /* Activate Hook Plugin */ register_activation_hook(__FILE__, 'ulh_add_user_logins_table'); /* call when plugin is activated */ function ulh_add_user_logins_table() { global $wpdb; $charset_collate = $wpdb->get_charset_collate(); ...


1

register_activation_hook() only attaches a function to run on activation of your plugin, not on updating. See the docs for full details, particularly this part: 3.1 : This hook is now fired only when the user activates the plugin and not when an automatic plugin update occurs (#14915). Of course, you could force your hook to run by deactivating and ...


0

You can achieve your task in both ways through plugin as well as coding Manually Please see the documentation on URLs of Namespaced Custom Post Types Identifiers. One of the options available to you is to add a 'rewrite' argument to register_post_type(). From the docs: Plugin Custom Post Type Permalinks allow you edit the permalink structure of custom ...


1

I am not sure I follow your question, title seems different from question itself. You seem to want to get rid of index.php in URL? It's hard to say confidently from outside, but it looks like PATHINFO permalink. If that's the case you would need to change your WP permalink configuration to more common "pretty" one. Doesn't have anything to do with CPT's ...


-1

Change or add the 'rewrite' => array( 'slug' => 'luckydraw', 'with_front' => false ), into the register_post_type arguments, This will change the slug of your custom post type.


2

You could filter the include paths returned by get_included_files by removing any files from the list that are not in your theme (and/or child theme) directory: function get_theme_includes() { $includedfiles = get_included_files(); // normalize theme paths for matching $styledir = str_replace("\\","/",get_stylesheet_directory()); ...


1

That's called Thickbox. Since you give no clue what you want to use it for, you'll have to figure out the rest for yourself...


2

Based on cjbj's answer above, this is what I did... I went to /wp-includes/admin-bar.php and copied the relevant code with a slight modification (see below) into my plugin. Here is the end result: if ( !current_user_can('edit_posts') ) return; $awaiting_mod = wp_count_comments(); $awaiting_mod = $awaiting_mod->moderated; $awaiting_text = sprintf( ...


0

Here is the final code to get sessions to write to the usermeta and delete on logout. This code works with WordPress 4.5.2. The code is for user_id information only. add_action( 'after_setup_theme', 'new_login' ); function new_login() { $user_id = ''; // Change your code to grab user_id from external source if ( $user_id > 0 && ! ...


1

The general implementation of such "pretty" permalinks in WordPress is realm of WP Rewrite. However it is pretty wide topic and low level code is a bit of abomination. I would say these are three most common techniques for it, complexity ascending: Use WordPress native data structures (such as Custom Post Types and/or Taxonomies) and benefit from ...


3

After you have removed the comments bubble, you add it again. The trick is that in the $args of add_node you have to set parent to top-secondary. So it will look like this: add_action( 'admin_bar_menu', 'wpse227079_toolbar_link_to_bubble', 999 ); function wpse227079_toolbar_link_to_bubble ( $wp_admin_bar ) { $args = array( 'id' ...


1

One way to move it to the very right would be like this: #wp-admin-bar-comments { float: right !important; } This will put it to the right of the Howdy message. I am not 100% sure if you want it on a specific side.


0

I see two options here - override the CSS, or remove the "active" classes with JavaScript (sadly there is no action/filter that we can do this server-side) - I opted for the JS approach, it's cleaner, leaner and meaner: function wpse_227037_remove_menu_classes() { echo '<script>jQuery( ".wp-has-current-submenu.wp-menu-open" ).removeClass( ...


0

The code is fine, I can't see any need to modify the query - I think you're missing the third argument in your get_post_meta call: $postACF_sc = get_post_meta($postId, 'sc_link', true /* $single */); You might also want to add this snippet just before the foreach to save multiple database queries: update_postmeta_cache( wp_list_pluck( $posts, 'posts_id' ...


0

To get the custom fields for a post you would need to add something like the following: d.meta_value (in the select clause) LEFT JOIN '.$var_setting['table_postmeta'].' d ON d.post_id = b.ID (in the from clause) I don't know the plugin so I can't promise it will work but this is how you join to the postmeta table to pull the custom fields. Hope ...


2

No, it is not possible to create third level menu in admin panel. If you look at the definition of add_submenu_page, you need to mention the parent slug name. For eg: add_menu_page ( 'Test Menu', 'Test Menu', 'read', 'testmainmenu', '', '' ); add_submenu_page ( 'testmainmenu', 'Test Menu', 'Child1', 'read', 'child1', ''); The first parameter of the ...


1

If you actually mean a main file (the one with header data) inside the plugin you can rename it freely. I think the only thing would happen is that it will deactivate on update and will need to be activated again by user. But if you mean plugin slug in the repository (the one in URL) — those are fixed in stone (or at least SVN) and cannot be changed.


0

Create a page for this purpose, which you can filter its content later UNLESS you are working other way. Add the page ID to the rewrite rule init function: add_action('init', function() { $page = get_post( 2 ); // replace 2 with page ID add_rewrite_rule( '([^/]+)/([^/]+)/?$', 'index.php?pagename=' . $page->post_name . ...


0

I would say the problem is first array. Change it to array( 'name' => $_POST['name'] ), You can also use wpdb->show_error() or wpdb->print_error() To Samuel Elh: wpdb->insert() can escape value itself


1

Disclaimer: I am not a lawyer. The issue here is the Apache license. You are free to distribute your own work under as many license varients as you want. After all you retain copyright. But if you include other peoples work in the distribution, every license varient you distribute under needs to be compatible. However, the Apache license is actually pretty ...


1

Not sure about the root cause, but you should avoid using relative paths to files. Because they are relative you never sure where exactly a file is being looked after. It might even become a security risk as PHP might look for the file in the default directories. The proper way is to use the plugin_dir_path, something like require_once ...


1

Actually you should skip the condition altogether - you don't need to worry about permissions or context here, you are merely saying: If WordPress, for whatever reason, is determining if a slug is bad: run my additional conditions Currently, if a theme/front-end plugin/REST API call was triggering the filter (i.e. insert/updating a post), your checks ...


0

I'd recommend setting up an API, and also ensuring the sites are HTTPS (have an SSL certificate) to encrypt communication between the servers. If you don't have one already, there are free certifiers such as https://letsencrypt.org/


-1

Great question. A couple of things: First, best practices tell us to always keep these types of assets outside of our Web server’s document root. PHP isn't limited by the same restrictions as a Web server, from a permissions perspective, so you can make a directory on the same level as your document root and place all of your sensitive data and code ...


0

include( plugin_dir_path( __FILE__ ) . 'ipn/paypal-ipn.php'); or define( 'PLUGIN_ROOT_DIR', plugin_dir_path( __FILE__ ) ); include( PLUGIN_ROOT_DIR . 'ipn/paypal-ipn.php'); or $plugin_dir_path = plugin_dir_path( __FILE__ ); include( $plugin_dir_path . 'ipn/paypal-ipn.php'); Note : to enqueu .css & .js files admin_enqueue_scripts inside plugin ...


0

You can not load external file in this way. This argument is for menu slug. If you load the external file it is useless, there will be nothing just except what you will print in file also there will be no WordPress functions at all (because WordPress is not loaded). You can define a callback function for this then include your red.php in that function. ...


0

In PHP, in too many contexts, false and true are more of a state of mind than actual values and not false is not the same as true If you want to check that something is a boolean true, then just check if it is === true. In your case the function returns a WP_Error object which is not a boolean value at all and it probably includes the reason for the ...


0

This is already possible meaning two people can logon using the same credentials on different computers. No additional plugins or code are required for this.


-1

You can create using page builders as well as using widgets or you can use custom post types and create page templates for different pages of your custom WordPress theme website.


0

Well just in case anyone else has this issue, my problem was that I was adding a post status of 'published' when I inserted the custom post type, rather than 'publish'. Hand meet forehead.



Top 50 recent answers are included