Tag Info

New answers tagged

0

Hey If you want to improving your text editor for post and pages then use Gust Wordpress Plugin Gust I think you like it.


0

The reason you get 0 back is because of the test at the end of the function: if ( ! empty( $query->posts ) && $query->is_singular ) return $query->post->ID; else return 0; The posts page doesn't pass the is_singular test so 0 is returned. If you have a URL and want to know if it's the posts page, you can match it against the ...


0

Take a look a this function, it may be useful. WP function get_page_by_path()


0

If you want to put PHP code in the editor you need a plugin, same goes for display-posts. Display Posts shortcode isn't a built in function. https://wordpress.org/plugins/display-posts-shortcode/


-1

Try this <?php echo do_shortcode('[display-posts id="1305"]'); ?>


0

If you have a page, and need to run PHP code that isn't in your standard page template, you can: Use a custom page template Create a template with page-pagename.php Implement and use a shortcode All three are valid and suitable methods for doing this, however, do not: Try to let users place actual PHP code in the post content ( MASSIVE security risk ) ...


0

I am not confident I am following your description completely, but verbatim from the documentation: If not given a theme_location parameter, the function displays the menu matching the ID, slug, or name given by the menu parameter; otherwise, the first non-empty menu; otherwise (or if the menu given by menu is empty), output of the ...


0

The is_user_logged_in function returns TRUE or FALSE, depending on the user’s status. <?php if (is_user_logged_in()) { ?> <p>Welcome, registered user!</p> <?php } else { // not logged in ?> <?php wp_redirect( wp_login_url() ); ?> <?php } ?> i think it work fine.


0

In your post list page do something like: <?php if (is_user_logged_in() ) { //show what you want to show to the logged in users } else { //show what you want to show to the general visitors (NOT logged in) //and/or redirect them to the login page wp_redirect( wp_login_url() ); exit; } ?>


-1

Have a look at this article by Michael Martin. I wanted to implement an "infinite scroll" on my site and he explained exactly what to do and how to do it. Maybe it will help you, who knows... It can be changed to load pages instead from a function.


0

I'm using this: if ( current_user_can('read_private_pages') ) With this condition, only Administrators and Editors can view the content of the page.


2

Previous Question That answer I've linked to shows the steps you'll need to take. It probably didn't come up in your searches as you weren't using the right terms. As you're a front-end dev, this is how I'd do it based on that persons advice. Don't load anything in the template. Just have an empty ul with an id you can target, and a button to use for the ...


0

I also was wondering how to incorporate anchors into my wp_query loop. The above code by Seamus was excellent, however I had to take out the # for the <div id="#post-<?php the_ID(); ?>"> line for it to work properly.


0

Here is the code I'm using: <?php global $custom_mb; // instead of using helper functions, you can also use ... $sch = get_post_meta(get_the_ID(), $custom_mb->get_the_id(), TRUE); foreach ($sch['docs'] as $img) { echo $img['imgurl']; } ?> Almost worked fine.


0

<?php global $post; if ( is_page('home') || is_page('services') ) { ?> <div class="col-md-2 col-sm-4"> <?php ci_e_logo('<h1 class="logo ' . get_logo_class() . '">', '</h1>'); ?> </div> <?php } elseif ( preg_match( '#^service(/.+)?$#', $wp->request ) ) { ?> <div class="col-md-2 ...


1

As you have stated, pages aren't meant to have categories. I would rather look into custom post types and taxonomies, but the implementation is still up to you as I don't know your structures I have never tried this before, neither do I know if this will actually work, but you can try the pre_get_posts action to amend the main query to display pages on your ...


0

$GLOBALS['pagenow'] doesn't work, use $_SERVER['PHP_SELF']. if ( in_array( $_SERVER['PHP_SELF'], array( '/wp-login.php', '/wp-register.php' ) ) ){ // do something. } and if your wordpress is not installed in the web root folder, you should use some params like YOUR_WP_PATH/wp-login.php to replace the elements in array.


0

You can get the Post page / post name using this method. $parent = array_reverse(get_post_ancestors($post->ID)); $page_parent = get_page($parent[0]); echo $page_parent->post_name; you can use the condition as per your requirements.


1

You can do that with $post->post_parent. You will have to check if child page's parent is Services page. So this is how you will check it. I assumed 123 in following code is page ID of your services page. Replace it with actual ID. if ( 123 == $post->post_parent ) { ?> <div class="col-md-2 col-sm-4"> <?php ci_e_logo('<h1 ...


-1

Use get_post_ancestors($post). It will return an array if the current shown post is child of your parent page.


0

Wordpress is a PHP program. This means that it starts up when it receives a HTTP request from the internet, it processes the request, sends the reply, and then shuts down. The system doesn't keep track of who is "logged in". The individual user keeps their credentials [username/password] in a cookie on their local browser. The cookie gets sent to the server, ...



Top 50 recent answers are included