Tag Info

New answers tagged

0

There are many options, but these functions are your friends: wp_insert_post - pass it some arguments and it will create a post and if succesful, return the post ID wp_set_object_terms - pass it a post ID, a custom taxonomy, and the terms you'd like to set fopen - for opening a csv file fgetcsv - reads in a single line from a csv and returns it for ...


0

You should really re-title this question and refine your question further. From what I gather you are actually trying to find out how to add posts to your custom post type that has custom fields via a CSV. My suggestion is to look for a plugin that imports posts from a CSV and either find one that already has a column for post_type and columns for custom ...


0

I was able to resolve this issue without using a separate theme or subdomain. I have elements of my theme that are loaded/not loaded on the server side based on the user agent (mobile/not mobile). After installing and enabling some basic caching with W3 Total Cache, I was getting desktop elements on mobile or vice versa. In W3 Total Cache User Agent Groups ...


0

I don't want to repeat the coding options since they have been exhaustively covered, the other option I know that works is using a plugin that hides wp. I have used this plugin before to satisfactory standards. Its called hide my WordPress.


0

The problem lies in your soto_user_meta_box_save function. This function is tied to the save_post action, which means it will fire whenever any post of any post type is saved, not just your custom post type. You need to add a check inside this function so it aborts when testing the wrong post type: function soto_user_meta_box_save( $post_id ) { // ...


0

If you're using Yoast's SEO plugin, you can set a default image for Facebook shares from the WordPress backend.


2

As you have already understated, running executable PHP inside a text box is not a good idea. It isn't only just not a good idea, but a terrible idea. This creates a loop hole in your security which can be very easily exploited by a hacker. I would suggest writing your own custom widget for this functionality. It is really easy adding a custom sidebar to ...


1

The PHP Code Widget does not modify the Text or Visual editor box, or the standard "Text" widget; it adds a "PHP Code" widget, which you'll find under Appearance > Widgets > Available Widgets. If you want to display your script within the body of the post or page, you should create a Shortcode. The basic example from the API would work for "Hello World"; ...


3

You can use is_paged() ...checks if page being displayed is "paged" and the current page number is greater than one. This is a boolean function, meaning it returns either TRUE or FALSE. You can adjust your code as follows <?php if( is_home() && !is_paged() ) : ?> <p>Some text</p> <?php endif;?>


1

You could do this with jquery. I have a similar code on use which you could probably easily edit to your needs: load the admin js (I load css too but you can remove that) function wpse181868_admin_css_js() { wp_register_style( 'bones_admin_css', get_template_directory_uri() . '/library/css/admin.css', false ); wp_enqueue_style( 'bones_admin_css' ...


0

If I understood correctly you need to show a specific category index on a page template, right? If that's the case you can use WP_Query: <?php /* Template Name: My Page Template */ ?> <?php get_header(); ?> <!-- If you want to retrieve the page title, content, ... --> <?php the_post(); // set up the post ?> <h1> ...


0

You have two options. Either use get_field or the_field. get_field just reads out the field from the db without and screenoutput. like you did in your first line: $fields = get_field('testimonial'); the_field instead is get_field with an implied echo. <?php the_field('testimonial'); ?> so basically the_field would be enough. Aside you have to ...


2

The question was for Wordpress 3.0, but just in case someone has the same question for a more recent version, from Wordpress Codex: "Starting with version 4.1, meta_query clauses can be nested in order to construct complex queries." http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters So that query should work on the current ...


0

Figured it out, you have to create a new class extending WP_Customize_Control: // Add Layout setting $wp_customize->add_setting( // ID 'sidebar_left_selection', // Arguments array array( 'default' => 'none', 'sanitize_callback' => 'webcodexcustomizer_sanitize_sidebar_selection' ) ); class ...


0

After a bit more research, I have found a way to do this from this post http://wordpress.stackexchange.com/a/136064/54989 Rather than using unset as I had done previously, remove_menu_page works for Duplicator: remove_menu_page( 'duplicator' ); so my complete code now looks like: function jitb_remove_admin_menu_items() { if ( !current_user_can( ...


2

Figure out a way to create multiple different custom post templates for an end-user. That is, have predefined regions that they can insert content within a post. You can do that with custom fields / meta boxes, which you can restrict or display based on post-type or ID. You should try the Advanced Custom Fields plugin. Or lastly, is there another ...


0

Given the way categories & tags are setup in WordPress this would not work from a logical standpoint. The issue here is that tags have no way to be connected directly to a category, they are mutually exclusive from each other. The subcategories would work because a subcategory is directly related to is parent category but tags are non hierarchical and ...


1

From what I can understand, you are talking about a static front page as you are referring to a template called homepage.php. The standard homepage uses index.php. To achieve 3 latest posts, you will need to create a custom query using WP_Query. I'm not sure which parameters you need, but feel free to read throught the given link and just add them as ...


1

You'll want a post type of type book, with a custom taxonomy for the publisher series. Use post meta for the books data. The UI will be provided by Core As a refresher: Things/objects/entities are post types We classify things using taxonomies. If you can filter by X, then X is a taxonomy, e.g. colour, type, size, shape, manufacturer, etc Attributes that ...


0

Two issues here Never use extract(). It has been removed from core functions, that should tell you a lot. For more info, check this trac ticket #22400 Your tax_query is incorrect, it should be an array of an array, yours is just an array Your shortcode should look something like this function course_listings( $atts ) { // Attributes $defaults ...


0

To get posts that belongs to all selected categories, you can make use of the category__and parameter. Example: You can the following to your query arguments, this will only display posts that are in category 1 AND 2 'category__and' => array( 1, 2 ),


0

You can use the_terms function in WP to display your term values in your archive page. Usage the_terms( $id, $taxonomy, $before, $sep, $after ); Parameters $id (int|req) -> Post ID. Default: None $taxonomy (str|req) -> Taxonomy name. Default: None $before (str|opt) -> Text to display before tags are displayed. Default: Empty string $sep (str|opt) -> ...


0

(I can't comment for being 50- reputation) I didn't understand your problem well. Choose or tell us; 1) Your post content have links and you want to add nofollow to links in custom fields which already used in content 2) You're writing your custom field's value already but just want to add nofollow. or tell us your scenario Update <a href="<?php ...


1

This is something you cannot change in the field it self, but in the template file. Copy and paste here the template file where this option is outputted. Another way will be to add a javascript snippet to you head, if you have such option in you template. Comment here and we'll see what the best solution is. Update: I think best solution for you is to ...


1

This will do what you want, and both functions should be placed within your fucntions.php file. The my_random_string() function accepts arguments, so you can add data before/after the string, as well as change the length of the string and the characters that are used to generate the string. /** * Generate a string of random characters * * @param array ...


2

Just FYI: After struggling for hours, I found the aswer. The line that was causing the problem is the following in my wp-config.php file: define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/'); It turned out my WP_SITEURL is not working correctly because I changed the directory structure as described in the question. So I modified wp-config.php ...


0

So far i know google appreciate a single instance of h1 tag in a page, but it could be anywhere at the priority content area. And all of WordPress front pages does have an element to use inside h1, such as post title, category name, search text, author name etc. Usually Blog or Front page doesn't have a Headline or title. So you could try adding it for the ...


1

It's doable with a user agent string "sniffer". Take a look at this project: http://mobiledetect.net Mind you, this approach can be troublesome as most modern browsers can 'fake' their user agent strings. Also, this approach doesn't work to well with caching systems. I've implemented it successfully on a project I worked on, and I know it's possible but ...


0

You can do this by checking if the post author is a contributor and post status is pending before the post is saved. Before the post is saved: add_filter( 'wp_insert_post_data', 'disallow_edit_pending_3748', 99, 2 ); function disallow_edit_pending_3748( $post_data, $post_array ){ if( 'pending' == $post_data['post_status'] && ...


2

There's no way to set this text directly. But, the "Empty Trash" text is run through the translation API before display. You can hijack this translation to replace the text with your own string. get_current_screen() is used to check the post_type of the current admin screen, so you can make sure you're only affecting your "task" type's screens. add_filter( ...


1

I know this post is somewhat older, but I thought I would point out that the previous answer only works if there is always a title. If you want to make sure that only the content of the widget gets wrapped in a panel-body class, you might want to try something like this: function my_widget_content_wrap($content) { $content = '<div ...


0

This soluton will create a metabox on your Edit Post screen and show you four additional form fields - Name Position Publications Freetext It will then save the data in to a corrisponding DB table, with each field in it's own column as you specified. As you have not provided a table name I have guessed at wp_additional_post_info, but you can change that ...


0

This approach is not advisable as http://example.com/page/whatever-information/ is how Wordpress deals with child pages and .htaccess Rewrites is part of how Wordpress identifies what page is being requested and what queries to run. You should probably pass the whatever-information as something called a POST variable, then have code that runs on page and ...


0

You can edit the login form from your child themes functions.php using actions such as: function my_login_scripts() { //do stuff here } add_action( 'login_enqueue_scripts', 'my_login_scripts' ); This should at least allow you to get your jQuery running on the page. You can read more about this here: ...


0

Where are you pasting that code? The code snippet needs to be put in the right spot. So you need to copy the content-product.php template from the woocommerce plugin folder and place it in your theme folder in a "woocommerce" folder. Then paste that code within the Loop. Updated Answer: Okay so I believe that you need to use the get_post_custom ...


0

The changes were being made in a stylesheet that is auto-generated by the parent theme. In the specific case of the Cherry parent theme (which is widely used in templates sold on themeforest, templatemonster etc), you cannot make stylesheet changes in reserved files such as main-styles.css (Despite them existing in a child theme). The solution is to either ...


0

You don't do that with your permalinks. You can do what you want in Wordpress Settings. Go to your Wordpress dashboard, 2. Click "Settings", 3. Click General. 4. In the "Site Address (URL)" Box remove the "blog" part like this --> "http://site.myurl.com/ NOTE: DON'T CHANGE THE WORDPRESS ADDRESS URL!!! Only change the Site Address Here is a screenshot ...



Top 50 recent answers are included