Tag Info

Hot answers tagged

4

To list all pages with title and permalink from one user you need $wpdb->get_results(). The following code is based on this answer: How to count current user's pages? First, we move the counter into a separate helper function; we might need it later again: /** * Get all post IDs and titles of a type for a user. * * @param int $user_id * @param ...


4

I tried for a bit and could not get this to work perfectly, but it's close, it's hard to extend with the <form> for the popup styles being hardcoded, thought possible with more work. To get started you can: Enqueue the link popup javascript and styles, the main .js file is wp-includes/wplink.js. Depending on where you loading this you might need to ...


3

Well if your code is working properly and the only problem is that it displays when no one is logged in then try the code below. Because right now you are saying "Hey WP just echo out this" - so it does it. You need to change it to: "Hey WP if the user is logged in show the link to his page and if not show the login link" like that: <?php if ( ...


3

There is no plugin to remove anchor tags with that url ( atleast I don't know any ), but you can replace the url with this plugin http://wordpress.org/plugins/search-and-replace/


3

You can use the Search Regex plugin. This will allow you to create a regular expression to intelligently search and replace across all of your posts. After you activate the plugin, go to Tools, Search Regex. If you want to remove all links to http://example.com, here is one regular expression you could try: /<a ...


3

You can get the current language with qtranslate using the function qtrans_getLanguage(); and then use it like this for conditionally showing content: <?php if ( qtrans_getLanguage() == 'en' ) { //put your code in here } elseif ( qtrans_getLanguage() == 'de' ) { //put your code in here } ?> ...


2

Nice one for using WordPress, but this is a straight-up HTML question. Nontheless... <div class="home-post-header"> <h2> <a href="<?php the_permalink() ?>"><?php the_title() ?></a> </h2> </div> h2's are considered block-level, whereas a & span are inline. Standards dictate that a ...


2

The pdf is itself an attachment post so in wordpress template hierarchy we can create a template named pdf.php Then you can write following code in it which force download the pdf file. <?php if (have_posts()) : the_post(); $pdf_title = $post->post_title; $pdf_src = get_attached_file($post->ID ); $bytes = filesize( $pdf_src ); ...


2

If you manually provide an excerpt for the post WordPress will use the one you provided instead of automatically generating one. Any HTML links you include in your manual excerpt will still be displayed correctly. Or you can leave the links out and just include the text you want. To preserve HTML links in the automatically generated excerpt you could try ...


2

The title attribute is hard-coded in comments_popup_link() unfortunately: echo ' title="' . esc_attr( sprintf( __('Comment on %s'), $title ) ) . '">'; What you can do is catching the generated HTML in a variable and replacing the attribute with an empty string: ob_start(); comments_popup_link(); print preg_replace( '~ title="[^"]+"~', '', ...


2

Add a rewrite rule and extra query vars to handle incoming requests, direct the rewrite rule to a single page post type, create a custom page template for that page, then do whatever querying you need using the query vars set by your rewrite rule.


2

Create a page with the name links. Pages >> Add New into your wordpress panel. Just name it links and publish. See below. Now go to your theme folder wp-content\themes\YOUR_ACTIVE_THEME_FOLDER and create a page page-links.php. And paste this code in page-links.php <?php $the_query = new WP_Query(array('post_type' => 'post')); ...


2

If you are talking about menus and your theme uses the Menu API, then upload the PDF to a publicly accessible server-- doesn't have to to be the one your site uses-- then go to Appearance -> Menus, Navigate to a menu, or create one find the "Links" dialogue, input the URL and the link text Save


2

Please refer to this link http://codex.wordpress.org/Changing_The_Site_URL It is possible to set the site URL manually in the wp-config.php file. Add these two lines to your wp-config.php, where "example.com" is the correct location of your site. define('WP_HOME','http://example.com'); define('WP_SITEURL','http://example.com');


1

Rather than "still on" page the user actually goes to the link and then sent back after post is deleted. From your description and quick look at code this is probably line that sends user back: wp_redirect( add_query_arg('deleted', 1, $sendback) ); Since destination is filtered inside wp_redirect() $location = apply_filters( 'wp_redirect', $location, ...


1

Have you tried something like: /*Get number of entries*/ function get_entries_num( $id ) { $count= count_user_posts( $id ); if ($count == 1) { return '<a href="'.get_author_posts_url($id).'">'.sprintf(__('%s total post','upme'), $count).'</a>'; } else { return '<a ...


1

Relative URLs are best avoided in WP, so use absolute URLs instead. Also, you should load javascript files using the correct method, ie by using the wp_enqueue_script() function hooked to the wp_enqueue_scripts action hook. Doing both of these things will sort out your issue. Using wp_enqueue_script() will also allow you to define dependencies so, for ...


1

Wordpress does in fact add a current class by default: check where it says: <li id="menu-item-1688" class="current-menu-item"> Within your source code. Now as for the other item, this is a bit tricky. There is two ways to do it assuming that you need the last item for styling. Option #1 is with pure CSS using the last-of-type selector. Option ...


1

Problem is that the function you use run after http header are sent, so it can't redirect. You have to use another way. One method can be intercept the global menu variable and add a new menu item with all properties: add_action( 'admin_menu', 'register_web_menu_page', 999); function register_web_menu_page () { global $menu; $menu[9] = array ( ...


1

I think this is almost what the article Add Private Content to Posts via Shortcode talks about. But it's only for registered users: add_shortcode('private', 'private_content'); function private_content($atts, $content = null) { if ( is_user_logged_in() ) return '<div class="private-content">' . $content . '</div>'; return ''; } ...


1

When in the Appearance > Menus admin screen, click the Screen Options tab in the upper right corner, then under Show advanced menu properties tick the Link Target box. You'll now have a check box for each menu item labeled Open link in a new window/tab. That said, many people these days do not take kindly to this sort of behavior. I think best practices ...


1

Arguments of wp_link_pages() Maybe this will work for you: $args = array( 'before' => '<ul><li>' . __( 'Pages:' ), 'after' => '</li></ul>', 'link_before' => '', 'link_after' => '', 'next_or_number' => ...


1

The page ID can vary in different installation, and it can't be changed, so an option is to use get_page_by_path because the page slug can be easily changed: <div class="my-link-box"> <?php $page = get_page_by_path('my-page'); ?> <a href="<?php echo get_permalink($page); ?>"><?php echo $page->post_title; ?></a> ...


1

I invoke the link dialogue within the metabox class I use for development. Its a tad hacky but can be done, until something more robust is developed. You can invoke the link box by first enqueing the required js, and then interacting with the wp-link js files methods. Make sure you have enqueued wp-link 1 / wp_enqueue_script( 'wp-link' ); 2 / Set up your ...


1

Create a page, call it "Blog" Settings->Reading... select your new "Blog" page in the drop down next "Posts page" In Appearance->Menus find your main menu. On the left, open up the "Pages" panel Find your page named Blog Check it and click "Add to Menu Save the menu Profit


1

What web addresses are in your Dashboard > Settings > general? if it is the old site, try changing it, if changing is impossible, try putting the following code at the top op wp-config.php: define('WP_HOME','http://www.new_site.com'); define('WP_SITEURL','http://www.new_site.com'); Are the site urls correct? Try searching your page template and see if you ...


1

You could use Gravity Forms and generate a draft of a custom post type on submission. The form could contain the URL and all other fields. Nice thing about Gravity Forms is the fields can all be validated and has decent anti-spam measures. It also has hooks to do other tasks such as the post-generation. When a form submission is received, it can send an ...


1

With markup embedded into the content there is no less tricky way than regex to do it, save perhaps a markup parser like SimpleHTMLDom function remove_image_link_102512($content) { $pattern = '|<a.*?href="(.*)".*>?(<img.*?/?>)(?:</a>)?|'; $content = preg_replace($pattern,'$2',$content); return $content; } ...


1

If the widget is part of the wordpress core, you can see its source in wp-includes/default-widgets.php. If it came with a theme or plugin, you can find the code there. Sometimes widgets will be in an obviously-named widgets.php, but other times you'll have to hunt for them. At some point, each widget has to be registered by calling register_widget. You can ...


1

This is how I would do it : 1/ create a filter to access the post content before it's displayed on page. See http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content 2/ Inside your fonction called (ie : my_the_content_filter in the example from the Codex) adapt this code : ...



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